Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
19854172 | 218 days ago | Contract Creation | 0 ETH |
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:
USTB
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 10000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity =0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {CrossChainToken} from "@tangible/tokens/CrossChainToken.sol"; import {LayerZeroRebaseTokenUpgradeable} from "@tangible/tokens/LayerZeroRebaseTokenUpgradeable.sol"; import {RebaseTokenUpgradeable} from "@tangible/tokens/RebaseTokenUpgradeable.sol"; import {IUSDM} from "./interfaces/IUSDM.sol"; import {IUSTB} from "./interfaces/IUSTB.sol"; /** * @title USTB (US T-Bill) * @author Caesar LaVey * @notice This contract extends the functionality of `LayerZeroRebaseTokenUpgradeable` to provide additional features * specific to USTB. It adds capabilities for minting and burning tokens backed by an underlying asset, and dynamically * updates the rebase index. * * @dev The contract uses SafeERC20 for secure ERC20 operations and introduces modifiers like `onlyIndexManager`, * `mainChain`, and `updateRebaseIndex` to conditionally execute functions. It also allows setting a rebase index * manager who has the permission to update the rebase index. */ contract USTB is IUSTB, LayerZeroRebaseTokenUpgradeable, UUPSUpgradeable { using SafeERC20 for IERC20; address public immutable UNDERLYING; /// @custom:storage-location erc7201:tangible.storage.USTB struct USTBStorage { address rebaseIndexManager; } // keccak256(abi.encode(uint256(keccak256("tangible.storage.USTB")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant USTBStorageLocation = 0x56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00; function _getUSTBStorage() private pure returns (USTBStorage storage $) { // slither-disable-next-line assembly assembly { $.slot := USTBStorageLocation } } modifier onlyIndexManager() { USTBStorage storage $ = _getUSTBStorage(); if (msg.sender != $.rebaseIndexManager && !_isInitializing()) { revert NotAuthorized(msg.sender); } _; } modifier mainChain(bool _isMainChain) { if (isMainChain != _isMainChain) { revert UnsupportedChain(block.chainid); } _; } /** * @param mainChainId The chain ID that represents the main chain. * @param endpoint The Layer Zero endpoint for cross-chain operations. * @custom:oz-upgrades-unsafe-allow constructor */ constructor(address underlying, uint256 mainChainId, address endpoint) CrossChainToken(mainChainId) LayerZeroRebaseTokenUpgradeable(endpoint) { UNDERLYING = underlying; _disableInitializers(); } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} /// @inheritdoc IUSTB function initialize(address indexManager) external initializer { __LayerZeroRebaseToken_init(msg.sender, "US T-Bill", "USTB"); if (isMainChain) { refreshRebaseIndex(); } else { setRebaseIndex(1 ether, 1); } setRebaseIndexManager(indexManager); } /// @inheritdoc IUSTB function mint(address to, uint256 amount) external mainChain(true) { _mint(to, amount); IERC20(UNDERLYING).safeTransferFrom(msg.sender, address(this), amount); } /// @inheritdoc IUSTB function burn(address from, uint256 amount) external mainChain(true) { if (from != msg.sender) { _spendAllowance(from, msg.sender, amount); } _burn(from, amount); IERC20(UNDERLYING).safeTransfer(msg.sender, amount); } /** * @notice Withdraws excess tokens from the contract balance that exceed the total supply accounted across all * satellite chains. * @dev This function is designed to manage excess tokens that result from rebases affecting the main chain's * contract balance while the satellite chains' balances remain unchanged due to users opting out of rebases. It * ensures the amount of tokens held by the contract does not exceed the sum of balances across all chains. This * function can only be called by the rebase index manager on the main chain. * * @param expectedBalance The expected amount of tokens that should remain in the contract after removing the * excess. This amount should be equivalent to the sum of all tokens across satellite chains. * @param index The current rebase index, which must match the contract's rebase index for the transaction to * proceed. This is used to verify that the rebase index has not changed during the transaction, ensuring * consistency. * @param recipient The address where the excess tokens will be sent. Must be a valid address, not the zero address. */ function withdrawExcessAmount(uint256 expectedBalance, uint256 index, address recipient) external mainChain(true) onlyIndexManager { if (recipient == address(0)) { revert InvalidZeroAddress(); } refreshRebaseIndex(); assert(index == rebaseIndex()); uint256 balance = balanceOf(address(this)); assert(balance > expectedBalance); uint256 excessAmount; unchecked { excessAmount = balance - expectedBalance; } _update(address(this), recipient, excessAmount); } /// @inheritdoc IUSTB function disableRebase(address account, bool disable) external { USTBStorage storage $ = _getUSTBStorage(); if (msg.sender != account && msg.sender != $.rebaseIndexManager) { revert NotAuthorized(msg.sender); } if (_isRebaseDisabled(account) == disable) { revert ValueUnchanged(); } _disableRebase(account, disable); } /// @inheritdoc IUSTB function rebaseIndexManager() external view override returns (address _rebaseIndexManager) { USTBStorage storage $ = _getUSTBStorage(); _rebaseIndexManager = $.rebaseIndexManager; } /// @inheritdoc IUSTB function setRebaseIndex(uint256 index, uint256 nonce) public onlyIndexManager mainChain(false) { _setRebaseIndex(index, nonce); } /// @inheritdoc IUSTB function refreshRebaseIndex() public { if (isMainChain) { uint256 currentIndex = IUSDM(UNDERLYING).rewardMultiplier(); if (currentIndex != rebaseIndex()) { _setRebaseIndex(currentIndex, block.number); } } } /// @inheritdoc IUSTB function setRebaseIndexManager(address manager) public onlyOwner { if (manager == address(0)) { revert InvalidZeroAddress(); } USTBStorage storage $ = _getUSTBStorage(); $.rebaseIndexManager = manager; emit RebaseIndexManagerUpdated(manager); } /** * @notice Updates the state of the contract during token transfers, mints, or burns. * @dev This override function performs an additional check to update the rebase index if the contract is on the * main chain. It fetches the current rebase index from the underlying asset and updates it if necessary. The * function then calls the original `_update` method to proceed with the state update. * * @param from The address from which tokens are being transferred or burned. * @param to The address to which tokens are being transferred or minted. * @param amount The amount of tokens being transferred, minted, or burned. */ function _update(address from, address to, uint256 amount) internal virtual override { refreshRebaseIndex(); super._update(from, to, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * 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. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC1967-compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {IOFTSubscriber} from "@layerzerolabs/contracts-upgradeable/token/oft/interfaces/IOFTSubscriber.sol"; abstract contract CrossChainToken { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable bool public immutable isMainChain; /// @custom:oz-upgrades-unsafe-allow constructor constructor(uint256 mainChainId) { isMainChain = mainChainId == block.chainid; } /** * @dev Attempts to notify the receiver of the credited amount. * Inline assembly is used to call the `notifyCredit` function on the receiver in order to prevent LayerZero's * ExcessivelySafeCall library from tagging the transaction as failed when this call fails. * * @param srcChainId The ID of the source chain where the message originated. * @param initiator The address of the initiator on the source chain. * @param sender The address on the source chain from which the tokens were sent. * @param receiver The address of the receiver who received tokens. * @param amount The amount of tokens credited. */ function _tryNotifyReceiver( uint16 srcChainId, address initiator, address sender, address, address receiver, uint256 amount ) internal returns (bool success) { bytes memory data = abi.encodeCall(IOFTSubscriber.notifyCredit, (srcChainId, initiator, sender, address(this), amount)); assembly { success := call( gas(), // gas remaining receiver, // destination address 0, // no ether add(data, 32), // input buffer (starts after the first 32 bytes in the `data` array) mload(data), // input length (loaded from the first 32 bytes in the `data` array) 0, // output buffer 0 // output length ) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {BytesLib} from "@layerzerolabs/contracts/libraries/BytesLib.sol"; import {OFTUpgradeable} from "@layerzerolabs/contracts-upgradeable/token/oft/v1/OFTUpgradeable.sol"; import {RebaseTokenMath} from "../libraries/RebaseTokenMath.sol"; import {CrossChainRebaseTokenUpgradeable} from "./CrossChainRebaseTokenUpgradeable.sol"; import {RebaseTokenUpgradeable} from "./RebaseTokenUpgradeable.sol"; /** * @title LayerZeroRebaseTokenUpgradeable * @author Caesar LaVey * @notice This contract extends the functionality of `CrossChainRebaseTokenUpgradeable` and implements * `OFTUpgradeable`. It is designed to support cross-chain rebase token transfers and operations in a LayerZero network. * * @dev The contract introduces a new struct, `Message`, to encapsulate the information required for cross-chain * transfers. This includes shares, the rebase index, and the rebase nonce. * * The contract overrides various functions like `totalSupply`, `balanceOf`, and `_update` to utilize the base * functionalities from `RebaseTokenUpgradeable`. * * It also implements specific functions like `_debitFrom` and `_creditTo` to handle LayerZero specific operations. */ abstract contract LayerZeroRebaseTokenUpgradeable is CrossChainRebaseTokenUpgradeable, OFTUpgradeable { using BytesLib for bytes; using RebaseTokenMath for uint256; struct Message { uint256 shares; uint256 rebaseIndex; uint256 nonce; } error CannotBridgeWhenOptedOut(address account); /** * @param endpoint The endpoint for Layer Zero operations. * @custom:oz-upgrades-unsafe-allow constructor */ constructor(address endpoint) OFTUpgradeable(endpoint) {} /** * @notice Initializes the LayerZeroRebaseTokenUpgradeable contract. * @dev This function is intended to be called once during the contract's deployment. It chains initialization logic * from `__LayerZeroRebaseToken_init_unchained`, `__CrossChainRebaseToken_init_unchained`, and `__OFT_init`. * * @param initialOwner The initial owner of the token contract. * @param name The name of the token. * @param symbol The symbol of the token. */ function __LayerZeroRebaseToken_init(address initialOwner, string memory name, string memory symbol) internal onlyInitializing { __LayerZeroRebaseToken_init_unchained(); __CrossChainRebaseToken_init_unchained(); __OFT_init(initialOwner, name, symbol); } function __LayerZeroRebaseToken_init_unchained() internal onlyInitializing {} function balanceOf(address account) public view override(IERC20, ERC20Upgradeable, RebaseTokenUpgradeable) returns (uint256) { return RebaseTokenUpgradeable.balanceOf(account); } function totalSupply() public view override(IERC20, ERC20Upgradeable, RebaseTokenUpgradeable) returns (uint256) { return RebaseTokenUpgradeable.totalSupply(); } function _update(address from, address to, uint256 amount) internal virtual override(ERC20Upgradeable, RebaseTokenUpgradeable) { RebaseTokenUpgradeable._update(from, to, amount); } /** * @notice Debits a specified amount of tokens from an account. * @dev This function performs a series of checks and operations to debit tokens from an account. If the account * has not opted out of rebasing, it calculates the share equivalent of the specified amount and updates the * internal state accordingly. If the operation occurs on the main chain, the tokens are moved to the contract's * address. Otherwise, the tokens are burned. * * @param from The address from which the tokens will be debited. * @param amount The amount to debit from the account. * @return shares The share equivalent of the debited amount. */ function _debitFrom(address from, uint16, bytes memory, uint256 amount) internal override returns (uint256 shares) { shares = _transferableShares(amount, from); if (from != msg.sender) { _spendAllowance(from, msg.sender, amount); } if (isMainChain) { _update(from, address(this), amount); } else { _update(from, address(0), amount); } } /** * @notice Credits a specified number of tokens to an account. * * @param to The address to which the shares will be credited. * @param shares The number of shares to credit to the account. * @return amount The token equivalent of the credited shares. */ function _creditTo(uint16, address to, uint256 shares) internal override returns (uint256 amount) { amount = shares.toTokens(rebaseIndex()); if (isMainChain) { _update(address(this), to, amount); } else { _update(address(0), to, amount); } return amount; } /** * @notice Initiates the sending of tokens to another chain. * @dev This function prepares a message containing the shares, rebase index, and nonce. It then uses LayerZero's * send functionality to send the tokens to the destination chain. The function checks adapter parameters and emits * a `SendToChain` event upon successful execution. * * @param from The address from which tokens are sent. * @param dstChainId The destination chain ID. * @param toAddress The address on the destination chain to which tokens will be sent. * @param amount The amount of tokens to send. * @param refundAddress The address for any refunds. * @param zroPaymentAddress The address for ZRO payment. * @param adapterParams Additional parameters for the adapter. */ function _send( address from, uint16 dstChainId, bytes memory toAddress, uint256 amount, address payable refundAddress, address zroPaymentAddress, bytes memory adapterParams ) internal override { if (optedOut(from)) { // tokens cannot be bridged if the account has opted out of rebasing revert CannotBridgeWhenOptedOut(from); } _checkAdapterParams(dstChainId, PT_SEND, adapterParams, NO_EXTRA_GAS); Message memory message = Message({ shares: _debitFrom(from, dstChainId, toAddress, amount), rebaseIndex: rebaseIndex(), nonce: _rebaseNonce() }); emit SendToChain(dstChainId, from, toAddress, message.shares.toTokens(message.rebaseIndex)); bytes memory lzPayload = abi.encode(PT_SEND, msg.sender, from, toAddress, message); _lzSend(dstChainId, lzPayload, refundAddress, zroPaymentAddress, adapterParams, msg.value); } /** * @notice Acknowledges the receipt of tokens from another chain and credits the correct amount to the recipient's * address. * @dev Upon receiving a payload, this function decodes it to extract the destination address and the message * content, which includes shares, rebase index, and nonce. If the current chain is not the main chain, it updates * the rebase index and nonce accordingly. Then, it credits the token shares to the recipient's address and emits a * `ReceiveFromChain` event. * * The function assumes that `_setRebaseIndex` handles the correctness of the rebase index and nonce update. * * @param srcChainId The source chain ID from which tokens are received. * @param srcAddressBytes The address on the source chain from which the message originated. * @param payload The payload containing the encoded destination address and message with shares, rebase index, and * nonce. */ function _sendAck(uint16 srcChainId, bytes memory srcAddressBytes, uint64, bytes memory payload) internal override { (, address initiator, address from, bytes memory toAddressBytes, Message memory message) = abi.decode(payload, (uint16, address, address, bytes, Message)); if (!isMainChain) { _setRebaseIndex(message.rebaseIndex, message.nonce); } address src = srcAddressBytes.toAddress(0); address to = toAddressBytes.toAddress(0); uint256 amount; amount = _creditTo(srcChainId, to, message.shares); _tryNotifyReceiver(srcChainId, initiator, from, src, to, amount); emit ReceiveFromChain(srcChainId, to, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {RebaseTokenMath} from "../libraries/RebaseTokenMath.sol"; /** * @title RebaseTokenUpgradeable * @author Caesar LaVey * @notice This is an upgradeable ERC20 token contract that introduces a rebase mechanism and allows accounts to opt out * of rebasing. The contract uses an index-based approach to implement rebasing, allowing for more gas-efficient * calculations. * * @dev The contract inherits from OpenZeppelin's ERC20Upgradeable and utilizes the RebaseTokenMath library for its * arithmetic operations. It introduces a new struct "RebaseTokenStorage" to manage its state. The state variables * include `rebaseIndex`, which is the current index value for rebasing, and `totalShares`, which is the total number of * index-based shares in circulation. * * The contract makes use of low-level Solidity features like assembly for optimized storage handling. It adheres to the * Checks-Effects-Interactions design pattern where applicable and emits events for significant state changes. */ abstract contract RebaseTokenUpgradeable is ERC20Upgradeable { using RebaseTokenMath for uint256; /// @custom:storage-location erc7201:tangible.storage.RebaseToken struct RebaseTokenStorage { uint256 rebaseIndex; uint256 totalShares; mapping(address => uint256) shares; mapping(address => bool) optOut; } // keccak256(abi.encode(uint256(keccak256("tangible.storage.RebaseToken")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant RebaseTokenStorageLocation = 0x8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00; function _getRebaseTokenStorage() private pure returns (RebaseTokenStorage storage $) { // slither-disable-next-line assembly assembly { $.slot := RebaseTokenStorageLocation } } event RebaseIndexUpdated(address updatedBy, uint256 index, uint256 totalSupplyBefore, uint256 totalSupplyAfter); event RebaseEnabled(address indexed account); event RebaseDisabled(address indexed account); error AmountExceedsBalance(address account, uint256 balance, uint256 amount); error RebaseOverflow(); error SupplyOverflow(); /** * @notice Initializes the RebaseTokenUpgradeable contract. * @dev This function should only be called once during the contract deployment. It internally calls * `__RebaseToken_init_unchained` for any further initializations and `__ERC20_init` to initialize the inherited * ERC20 contract. * * @param name The name of the token. * @param symbol The symbol of the token. */ function __RebaseToken_init(string memory name, string memory symbol) internal onlyInitializing { __RebaseToken_init_unchained(); __ERC20_init(name, symbol); } function __RebaseToken_init_unchained() internal onlyInitializing {} /** * @notice Enables or disables rebasing for a specific account. * @dev This function updates the `optOut` mapping for the `account` based on the `disable` flag. It also adjusts * the shares and token balances accordingly if the account has a non-zero balance. This function emits either a * `RebaseEnabled` or `RebaseDisabled` event. * * @param account The address of the account for which rebasing is to be enabled or disabled. * @param disable A boolean flag indicating whether to disable (true) or enable (false) rebasing for the account. */ function _disableRebase(address account, bool disable) internal { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); if ($.optOut[account] != disable) { uint256 balance = balanceOf(account); if (balance != 0) { if (disable) { RebaseTokenUpgradeable._update(account, address(0), balance); } else { ERC20Upgradeable._update(account, address(0), balance); } } $.optOut[account] = disable; if (balance != 0) { if (disable) { ERC20Upgradeable._update(address(0), account, balance); } else { RebaseTokenUpgradeable._update(address(0), account, balance); } } if (disable) emit RebaseDisabled(account); else emit RebaseEnabled(account); } } /** * @notice Checks if rebasing is disabled for a specific account. * @dev This function fetches the `optOut` status from the contract's storage for the specified `account`. * * @param account The address of the account to check. * @return disabled A boolean indicating whether rebasing is disabled (true) or enabled (false) for the account. */ function _isRebaseDisabled(address account) internal view returns (bool disabled) { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); disabled = $.optOut[account]; } /** * @notice Returns the current rebase index of the token. * @dev This function fetches the `rebaseIndex` from the contract's storage and returns it. The returned index is * used in various calculations related to token rebasing. * * @return index The current rebase index. */ function rebaseIndex() public view returns (uint256 index) { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); index = $.rebaseIndex; } /** * @notice Returns the balance of a specific account, adjusted for the current rebase index. * @dev This function fetches the `shares` and `rebaseIndex` from the contract's storage for the specified account. * It then calculates the balance in tokens by converting these shares to their equivalent token amount using the * current rebase index. * * @param account The address of the account whose balance is to be fetched. * @return balance The balance of the specified account in tokens. */ function balanceOf(address account) public view virtual override returns (uint256 balance) { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); if ($.optOut[account]) { balance = ERC20Upgradeable.balanceOf(account); } else { balance = $.shares[account].toTokens($.rebaseIndex); } } /** * @notice Returns whether rebasing is disabled for a specific account. * @param account The address of the account to check. */ function optedOut(address account) public view returns (bool) { return _isRebaseDisabled(account); } /** * @notice Returns the total supply of the token, taking into account the current rebase index. * @dev This function fetches the `totalShares` and `rebaseIndex` from the contract's storage. It then calculates * the total supply of tokens by converting these shares to their equivalent token amount using the current rebase * index. * * @return supply The total supply of tokens. */ function totalSupply() public view virtual override returns (uint256 supply) { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); supply = $.totalShares.toTokens($.rebaseIndex) + ERC20Upgradeable.totalSupply(); } /** * @notice Sets a new rebase index for the token. * @dev This function updates the `rebaseIndex` state variable if the new index differs from the current one. It * also performs a check for any potential overflow conditions that could occur with the new index. Emits a * `RebaseIndexUpdated` event upon successful update. * * @param index The new rebase index to set. */ function _setRebaseIndex(uint256 index) internal virtual { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); uint256 currentIndex = $.rebaseIndex; if (currentIndex != index) { $.rebaseIndex = index; _checkRebaseOverflow($.totalShares, index); uint256 constantSupply = ERC20Upgradeable.totalSupply(); uint256 totalSupplyBefore = $.totalShares.toTokens(currentIndex) + constantSupply; uint256 totalSupplyAfter = $.totalShares.toTokens(index) + constantSupply; emit RebaseIndexUpdated(msg.sender, index, totalSupplyBefore, totalSupplyAfter); } } /** * @notice Calculates the number of transferable shares for a given amount and account. * @dev This function fetches the current rebase index and the shares held by the `from` address. It then converts * these shares to the equivalent token balance. If the `amount` to be transferred exceeds this balance, the * function reverts with an `AmountExceedsBalance` error. Otherwise, it calculates the number of shares equivalent * to the `amount` to be transferred. * * @param amount The amount of tokens to be transferred. * @param from The address from which the tokens are to be transferred. * @return shares The number of shares equivalent to the `amount` to be transferred. */ function _transferableShares(uint256 amount, address from) internal view returns (uint256 shares) { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); shares = $.shares[from]; uint256 index = $.rebaseIndex; uint256 balance = shares.toTokens(index); if (amount > balance) { revert AmountExceedsBalance(from, balance, amount); } if (amount < balance) { shares = amount.toShares(index); } } /** * @notice Updates the state of the contract during token transfers, mints, or burns. * @dev This function adjusts the `totalShares` and individual `shares` of `from` and `to` addresses based on their * rebasing status (`optOut`). When both parties have opted out of rebasing, the standard ERC20 `_update` is called * instead. It performs overflow and underflow checks where necessary and delegates to the parent function when * opt-out applies. * * @param from The address from which tokens are transferred or burned. Address(0) implies minting. * @param to The address to which tokens are transferred or minted. Address(0) implies burning. * @param amount The amount of tokens to be transferred. */ function _update(address from, address to, uint256 amount) internal virtual override { RebaseTokenStorage storage $ = _getRebaseTokenStorage(); bool optOutFrom = $.optOut[from]; bool optOutTo = $.optOut[to]; if (optOutFrom && optOutTo) { ERC20Upgradeable._update(from, to, amount); return; } uint256 index = $.rebaseIndex; uint256 shares = amount.toShares(index); if (from == address(0)) { if (optOutTo) { _checkTotalSupplyOverFlow(amount); } else { uint256 totalShares = $.totalShares + shares; // Overflow check required _checkRebaseOverflow(totalShares, index); $.totalShares = totalShares; } } else { if (optOutFrom) { amount = shares.toTokens(index); ERC20Upgradeable._update(from, address(0), amount); } else { shares = _transferableShares(amount, from); unchecked { // Underflow not possible: `shares <= $.shares[from] <= totalShares`. if (optOutTo && to != address(0)) $.totalShares -= shares; $.shares[from] -= shares; } } } if (to == address(0)) { if (!optOutFrom) { unchecked { // Underflow not possible: `shares <= $.totalShares` or `shares <= $.shares[from] <= $.totalShares`. $.totalShares -= shares; } } } else { if (optOutTo) { // At this point we know that `from` has not opted out. ERC20Upgradeable._update(address(0), to, amount); } else { // At this point we know that `from` has opted out. unchecked { // Overflow not possible: `$.shares[to] + shares` is at most `$.totalShares`, which we know fits // into a `uint256`. $.shares[to] += shares; if (optOutFrom && from != address(0)) $.totalShares += shares; } } } if (optOutFrom) from = address(0); if (optOutTo) to = address(0); if (from != to) { emit Transfer(from, to, shares.toTokens(index)); } } /** * @notice Checks for potential overflow conditions in token-to-share calculations. * @dev This function uses an `assert` statement to ensure that converting shares to tokens using the provided * `index` will not result in an overflow. It leverages the `toTokens` function from the `RebaseTokenMath` library * to perform this check. * * @param shares The number of shares involved in the operation. * @param index The current rebase index. */ function _checkRebaseOverflow(uint256 shares, uint256 index) private view { // Using an unchecked block to avoid overflow checks, as overflow will be handled explicitly. uint256 _elasticSupply = shares.toTokens(index); unchecked { if (_elasticSupply + ERC20Upgradeable.totalSupply() < _elasticSupply) { revert RebaseOverflow(); } } } /** * @notice Checks for potential overflow conditions in USTB totalSupply. * @dev This function ensures whenever a new mint, the addition of * new mintedAmount + totalShares + ERC20Upgradeable.totalSupply() doesn't over flow * * @param amount The amount of tokens involved in the operation. */ function _checkTotalSupplyOverFlow(uint256 amount) private view { unchecked { uint256 _totalSupply = totalSupply(); if (amount + _totalSupply < _totalSupply) { revert SupplyOverflow(); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IUSDM { function rewardMultiplier() external view returns (uint256 multiplier); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; interface IUSTB { event RebaseIndexManagerUpdated(address manager); error InvalidZeroAddress(); error NotAuthorized(address caller); error UnsupportedChain(uint256 chainId); error ValueUnchanged(); /** * Returns the underlying address. */ function UNDERLYING() external view returns (address); /** * @notice Initializes the USTB contract with essential parameters. * @dev This function sets the initial LayerZero endpoint and the rebase index manager. It also calls * `__LayerZeroRebaseToken_init` for further initialization. * * @param indexManager The address that will manage the rebase index. */ function initialize(address indexManager) external; /** * @notice Burns a specified amount of USTB tokens from a given address. * @dev This function first burns the specified amount of USTB tokens from the target address. Then, it transfers * the equivalent amount of the underlying asset back to the caller. The function can only be called if the contract * is on the main chain. It also updates the rebase index before burning. * * @param from The address from which the tokens will be burned. * @param amount The amount of tokens to burn. */ function burn(address from, uint256 amount) external; /** * @notice Mints a specified amount of USTB tokens to a given address. * @dev This function first transfers the underlying asset from the caller to the contract. Then, it mints the * equivalent amount of USTB tokens to the target address. The function can only be called if the contract is on the * main chain. It also updates the rebase index before minting. * * @param to The address to which the tokens will be minted. * @param amount The amount of tokens to mint. */ function mint(address to, uint256 amount) external; /** * @notice Enables or disables rebasing for a specific account. * @dev This function can be called by either the account itself or the rebase index manager. * * @param account The address of the account for which rebasing is to be enabled or disabled. * @param disable A boolean flag indicating whether to disable (true) or enable (false) rebasing for the account. */ function disableRebase(address account, bool disable) external; /** * @notice Sets the rebase index and its corresponding nonce on non-main chains. * @dev This function allows the rebase index manager to manually update the rebase index and nonce when not on the * main chain. The main chain manages the rebase index automatically within `refreshRebaseIndex`. It should only be * used on non-main chains to align them with the main chain's state. * * Reverts if called on the main chain due to the `mainChain(false)` modifier. * * @param index The new rebase index to set. * @param nonce The new nonce corresponding to the rebase index. */ function setRebaseIndex(uint256 index, uint256 nonce) external; /** * @notice Returns the address of rebase index manager. */ function rebaseIndexManager() external view returns (address _rebaseIndexManager); /** * @notice Updates the rebase index to the current index from the underlying asset on the main chain. * @dev Automatically refreshes the rebase index by querying the current reward multiplier from the underlying asset * contract. This can only affect the rebase index on the main chain. If the current index from the underlying * differs from the stored rebase index, it updates the rebase index and sets the current block number as the nonce. * * This function does not have effect on non-main chains as their rebase index and nonce are managed through * `setRebaseIndex`. */ function refreshRebaseIndex() external; /** * @notice Sets the address of the rebase index manager. * @dev This function allows the contract owner to change the rebase index manager, who has the permission to update * the rebase index. * * @param manager The new rebase index manager address. */ function setRebaseIndexManager(address manager) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @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 v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.20; import {IBeacon} from "../beacon/IBeacon.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. */ library ERC1967Utils { // We re-declare ERC-1967 events here because they can't be used directly from IERC1967. // This will be fixed in Solidity 0.8.21. At that point we should remove these events. /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (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 pragma solidity >=0.5.0; /** * @dev Interface of the OFT subscriber */ interface IOFTSubscriber { /** * @notice Notifies the contract about a token credit from a source chain. * @dev This function allows external systems to inform the contract about credited tokens. * @param srcChainId Chain ID of the source chain. * @param initiator Address of the initiator on the source chain. * @param sender The address on the source chain from which the tokens were sent. * @param token Address of the credited token. * @param amount Amount of tokens credited. */ function notifyCredit(uint16 srcChainId, address initiator, address sender, address token, uint256 amount) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors { /// @custom:storage-location erc7201:openzeppelin.storage.ERC20 struct ERC20Storage { mapping(address account => uint256) _balances; mapping(address account => mapping(address spender => uint256)) _allowances; uint256 _totalSupply; string _name; string _symbol; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20Storage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20StorageLocation } } /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { ERC20Storage storage $ = _getERC20Storage(); $._name = name_; $._symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows $._totalSupply += value; } else { uint256 fromBalance = $._balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. $._balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. $._totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. $._balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } $._allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ) ) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00), and(mload(mc), mask))) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint _start, uint _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1, "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint _start) internal pure returns (uint) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for { } eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {IERC20, ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {IOFT} from "@layerzerolabs/contracts/token/oft/v1/interfaces/IOFT.sol"; import {OFTCoreUpgradeable} from "./OFTCoreUpgradeable.sol"; /** * @title OFTUpgradeable * @dev This contract is an upgradable implementation of LayerZero's Omnichain Fungible Tokens (OFT) standard. * It inherits the core functionalities from OFTCoreUpgradeable and extends it by adding ERC-20 token functionalities. * This contract is designed to allow the token to be transacted across different blockchains in a seamless manner. * * Key methods include `_debitFrom` and `_creditTo`, which are overridden to handle the actual token transactions. * This contract is also compatible with the ERC-165 standard for contract introspection. */ contract OFTUpgradeable is OFTCoreUpgradeable, ERC20Upgradeable, IOFT { /** * @param endpoint The address of the LayerZero endpoint. * @custom:oz-upgrades-unsafe-allow constructor */ constructor(address endpoint) OFTCoreUpgradeable(endpoint) {} /** * @dev Initializes the OFT token with a given name and symbol. * It sets the state within this contract and also initializes the inherited ERC20 token with the given name and * symbol. * This function should only be called during the contract initialization phase. * * @param initialOwner The address of the initial owner. * @param name The name of the token. * @param symbol The symbol of the token. */ function __OFT_init(address initialOwner, string memory name, string memory symbol) internal onlyInitializing { __OFT_init_unchained(); __OFTCore_init(initialOwner); __ERC20_init(name, symbol); } function __OFT_init_unchained() internal onlyInitializing {} /** * @dev Implements the ERC165 standard for contract introspection. * Extends the functionality to include the interface IDs of IOFT and IERC20, alongside the inherited interfaces. * * @param interfaceId The interface identifier, as specified in ERC-165. * @return `true` if the contract implements the interface represented by `interfaceId`, otherwise `false`. */ function supportsInterface(bytes4 interfaceId) public view virtual override(OFTCoreUpgradeable, IERC165) returns (bool) { return interfaceId == type(IOFT).interfaceId || interfaceId == type(IERC20).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Retrieves the address of the OFT token, which is the address of this contract. * This function is part of the IOFT interface. * * @return The address of this OFT token contract. */ function token() public view virtual override returns (address) { return address(this); } /** * @dev Returns the total circulating supply of OFT tokens. * In this implementation, it's equivalent to the total supply as managed by the ERC20 standard. * This function is part of the IOFT interface. * * @return The total circulating supply of OFT tokens. */ function circulatingSupply() public view virtual override returns (uint256) { return totalSupply(); } /** * @dev Handles the token debit operation when sending tokens to another chain. * Burns the specified amount of tokens from the sender's account. * * @param from The address of the token holder. * @param amount The amount of tokens to be debited (burned). * @return The actual amount of tokens that were debited. */ function _debitFrom(address from, uint16, bytes memory, uint256 amount) internal virtual override returns (uint256) { address spender = _msgSender(); if (from != spender) _spendAllowance(from, spender, amount); _burn(from, amount); return amount; } /** * @dev Handles the token credit operation when receiving tokens from another chain. * Mints the specified amount of tokens to the recipient's account. * * @param toAddress The address of the recipient. * @param amount The amount of tokens to be credited (minted). * @return The actual amount of tokens that were credited. */ function _creditTo(uint16, address toAddress, uint256 amount) internal virtual override returns (uint256) { _mint(toAddress, amount); return amount; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; /** * @title RebaseTokenMath * @author Caesar LaVey * @dev A library that provides functions to convert between token amounts and shares in the context of a rebase * mechanism. * * Note: This library assumes that 1 ether is used as the base unit for the rebase index. */ library RebaseTokenMath { /** * @dev Converts a token amount to its equivalent shares using the rebase index. * The function uses the formula: shares = (amount * 1 ether) / rebaseIndex * * @param amount The token amount to be converted. * @param rebaseIndex The current rebase index. * @return shares The equivalent shares for the given token amount. */ function toShares(uint256 amount, uint256 rebaseIndex) internal pure returns (uint256 shares) { shares = Math.mulDiv(amount, 1 ether, rebaseIndex); } /** * @dev Converts shares to their equivalent token amount using the rebase index. * The function uses the formula: amount = (shares * rebaseIndex) / 1 ether * * @param shares The number of shares to be converted. * @param rebaseIndex The current rebase index. * @return amount The equivalent token amount for the given shares. */ function toTokens(uint256 shares, uint256 rebaseIndex) internal pure returns (uint256 amount) { amount = Math.mulDiv(shares, rebaseIndex, 1 ether); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {CrossChainToken} from "./CrossChainToken.sol"; import {RebaseTokenUpgradeable} from "./RebaseTokenUpgradeable.sol"; /** * @title CrossChainRebaseTokenUpgradeable * @author Caesar LaVey * @notice This contract extends the functionality of `RebaseTokenUpgradeable` by enabling cross-chain rebase * operations. It also implements the `ICrossChain` interface. * * @dev The contract introduces a nonce mechanism to facilitate cross-chain interactions. It has a new struct, * `CrossChainRebaseTokenStorage`, to manage this additional state. * * The contract overrides the `_setRebaseIndex` function to add nonce-based verification. It provides a new function * `_setRebaseIndex(uint256 index, uint256 nonce)` to be used in place of the original `_setRebaseIndex` function. * * It also includes functions for nonce management and verification. */ abstract contract CrossChainRebaseTokenUpgradeable is RebaseTokenUpgradeable, CrossChainToken { /// @custom:storage-location erc7201:tangible.storage.CrossChainRebaseToken struct CrossChainRebaseTokenStorage { uint256 nonce; } // keccak256(abi.encode(uint256(keccak256("tangible.storage.CrossChainRebaseToken")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant CrossChainRebaseTokenStorageLocation = 0xdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b500; function _getCrossChainRebaseTokenStorage() private pure returns (CrossChainRebaseTokenStorage storage $) { // slither-disable-next-line assembly assembly { $.slot := CrossChainRebaseTokenStorageLocation } } /** * @notice Initializes the CrossChainRebaseTokenUpgradeable contract. * @dev This function should only be called once during the contract deployment. It internally calls * `__CrossChainRebaseToken_init_unchained` for any further initializations and `__RebaseToken_init` to initialize * the inherited RebaseTokenUpgradeable contract. * * @param name The name of the token. * @param symbol The symbol of the token. */ function __CrossChainRebaseToken_init(string memory name, string memory symbol) internal onlyInitializing { __CrossChainRebaseToken_init_unchained(); __RebaseToken_init(name, symbol); } function __CrossChainRebaseToken_init_unchained() internal onlyInitializing {} /** * @notice Retrieves the current rebase nonce. * @dev The function fetches the current nonce from the `CrossChainRebaseTokenStorage` struct. The nonce is used in * cross-chain rebase operations to ensure the correct sequence of operations. * * @return nonce The current rebase nonce. */ function _rebaseNonce() internal view returns (uint256 nonce) { CrossChainRebaseTokenStorage storage $ = _getCrossChainRebaseTokenStorage(); nonce = $.nonce; } function _setRebaseIndex(uint256) internal pure override { revert("use: _setRebaseIndex(uint256 index, uint256 nonce)"); } /** * @notice Sets a new rebase index if the provided nonce is valid and updates the rebase nonce if it's different * from the current nonce. * @dev This function checks that the provided nonce is greater than or equal to the current stored nonce before * setting the new rebase index. If the nonce is greater than the stored nonce, the stored nonce is updated to the * new value. It relies on `_setRebaseIndex` from the `RebaseTokenUpgradeable` contract to change the rebase index. * If the provided nonce is less than the current nonce, no changes occur. * * @param index The new rebase index to set. * @param nonce The rebase nonce for this operation, which must be greater than or equal to the current nonce. */ function _setRebaseIndex(uint256 index, uint256 nonce) internal virtual { CrossChainRebaseTokenStorage storage $ = _getCrossChainRebaseTokenStorage(); uint256 rebaseNonce = $.nonce; if (nonce >= rebaseNonce) { RebaseTokenUpgradeable._setRebaseIndex(index); if (nonce != rebaseNonce) { $.nonce = nonce; } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./IOFTCore.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @dev Interface of the OFT standard */ interface IOFT is IOFTCore, IERC20 { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {IERC165, ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import {IOFTCore} from "@layerzerolabs/contracts/token/oft/v1/interfaces/IOFTCore.sol"; import {BytesLib} from "@layerzerolabs/contracts/libraries/BytesLib.sol"; import {NonblockingLzAppUpgradeable} from "../../../lzApp/NonblockingLzAppUpgradeable.sol"; import {IOFTSubscriber} from "../interfaces/IOFTSubscriber.sol"; /** * @title OFTCoreUpgradeable * @dev This contract extends NonblockingLzAppUpgradeable to provide a core implementation for OFT (On-Chain Forwarding * Token). It introduces packet types, custom adapter params, and methods for sending and receiving tokens across * chains. * * This contract is intended to be inherited by other contracts that implement specific token logic. * * Packet Types: * - PT_SEND: Packet type for sending tokens. Value is 0. * * Custom Adapter Params: * - The contract allows for the use of custom adapter parameters which affect the gas usage for cross-chain operations. * * Storage: * - useCustomAdapterParams: A flag to indicate whether to use custom adapter parameters. */ abstract contract OFTCoreUpgradeable is NonblockingLzAppUpgradeable, ERC165, IOFTCore { using BytesLib for bytes; uint256 public constant NO_EXTRA_GAS = 0; // packet type uint16 public constant PT_SEND = 0; /// @custom:storage-location erc7201:layerzero.storage.OFTCore struct OFTCoreStorage { bool useCustomAdapterParams; } // keccak256(abi.encode(uint256(keccak256("layerzero.storage.OFTCore")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OFTCoreStorageLocation = 0x822492242235517548c4a8cf040400e3c0daf5b82af652ed16dce4fa3ae72800; function _getOFTCoreStorage() private pure returns (OFTCoreStorage storage $) { // slither-disable-next-line assembly assembly { $.slot := OFTCoreStorageLocation } } /** * @param endpoint The address of the LayerZero endpoint. * @custom:oz-upgrades-unsafe-allow constructor */ constructor(address endpoint) NonblockingLzAppUpgradeable(endpoint) {} /** * @dev Initializes the contract state for `OFTCoreUpgradeable`. * Calls the initialization functions of parent contracts. * * @param initialOwner The address of the initial owner. */ function __OFTCore_init(address initialOwner) internal onlyInitializing { __OFTCore_init_unchained(); __NonblockingLzApp_init(initialOwner); } function __OFTCore_init_unchained() internal onlyInitializing {} /** * @dev Checks if the contract supports a given interface ID. * Overrides the implementation in ERC165 to include support for IOFTCore. * * @param interfaceId The ID of the interface to check. * @return bool `true` if the contract supports the given interface ID, `false` otherwise. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IOFTCore).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Estimates the fee required for sending tokens to a different chain. * This function is part of the IOFTCore interface. * * @param dstChainId The ID of the destination chain. * @param toAddress The address to which the tokens will be sent on the destination chain. * @param amount The amount of tokens to send. * @param useZro Flag indicating whether to use ZRO for payment. * @param adapterParams Additional parameters for the adapter. * @return nativeFee The estimated native chain fee. * @return zroFee The estimated ZRO fee. */ function estimateSendFee( uint16 dstChainId, bytes calldata toAddress, uint256 amount, bool useZro, bytes calldata adapterParams ) public view virtual override returns (uint256 nativeFee, uint256 zroFee) { // mock the payload for sendFrom() bytes memory payload = abi.encode(PT_SEND, toAddress, amount); return lzEndpoint.estimateFees(dstChainId, address(this), payload, useZro, adapterParams); } /** * @dev Sends tokens from a given address to a destination address on another chain. * This function is part of the IOFTCore interface. * * @param from The address from which tokens will be sent. * @param dstChainId The ID of the destination chain. * @param toAddress The address on the destination chain to which tokens will be sent. * @param amount The amount of tokens to send. * @param refundAddress The address where any excess native fee will be refunded. * @param zroPaymentAddress The address used for ZRO payments, if applicable. * @param adapterParams Additional parameters for the adapter. */ function sendFrom( address from, uint16 dstChainId, bytes calldata toAddress, uint256 amount, address payable refundAddress, address zroPaymentAddress, bytes calldata adapterParams ) public payable virtual override { _send(from, dstChainId, toAddress, amount, refundAddress, zroPaymentAddress, adapterParams); } /** * @dev Toggles the use of custom adapter parameters. * When enabled, the contract will check gas limits based on the provided adapter parameters. * * @param useCustomAdapterParams Flag indicating whether to use custom adapter parameters. */ function setUseCustomAdapterParams(bool useCustomAdapterParams) public virtual onlyOwner { OFTCoreStorage storage $ = _getOFTCoreStorage(); $.useCustomAdapterParams = useCustomAdapterParams; emit SetUseCustomAdapterParams(useCustomAdapterParams); } /** * @dev Handles incoming messages from other chains in a non-blocking fashion. * This function overrides the abstract implementation in NonblockingLzAppUpgradeable. * * @param srcChainId The ID of the source chain. * @param srcAddress The address on the source chain from which the message originated. * @param nonce A unique identifier for the message. * @param payload The actual data sent from the source chain. */ function _nonblockingLzReceive(uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload) internal virtual override { uint16 packetType; // slither-disable-next-line assembly assembly { packetType := mload(add(payload, 32)) } if (packetType == PT_SEND) { _sendAck(srcChainId, srcAddress, nonce, payload); } else { revert("OFTCore: unknown packet type"); } } /** * @dev Performs the actual sending of tokens to a destination chain. * This internal function is called by the public wrapper `sendFrom`. * * @param from The address from which tokens are sent. * @param dstChainId The ID of the destination chain. * @param toAddress The address on the destination chain where tokens will be sent. * @param amount The amount of tokens to send. * @param refundAddress The address for refunding any excess native fee. * @param zroPaymentAddress The address for ZRO payment, if applicable. * @param adapterParams Additional parameters for the adapter. */ function _send( address from, uint16 dstChainId, bytes memory toAddress, uint256 amount, address payable refundAddress, address zroPaymentAddress, bytes memory adapterParams ) internal virtual { _checkAdapterParams(dstChainId, PT_SEND, adapterParams, NO_EXTRA_GAS); amount = _debitFrom(from, dstChainId, toAddress, amount); bytes memory lzPayload = abi.encode(PT_SEND, toAddress, amount); _lzSend(dstChainId, lzPayload, refundAddress, zroPaymentAddress, adapterParams, msg.value); emit SendToChain(dstChainId, from, toAddress, amount); } /** * @dev Acknowledges the reception of tokens sent from another chain. * This function is called internally when a PT_SEND packet type is received. * * @param srcChainId The ID of the source chain from which the tokens were sent. * @param payload The payload containing the details of the sent tokens. */ function _sendAck(uint16 srcChainId, bytes memory, uint64, bytes memory payload) internal virtual { (, bytes memory toAddressBytes, uint256 amount) = abi.decode(payload, (uint16, bytes, uint256)); address to = toAddressBytes.toAddress(0); amount = _creditTo(srcChainId, to, amount); emit ReceiveFromChain(srcChainId, to, amount); } /** * @dev Validates the adapter parameters for sending tokens. * This function can be configured to either enforce a gas limit or to accept custom parameters. * * @param dstChainId The ID of the destination chain. * @param pkType The packet type of the message. * @param adapterParams The additional parameters for the adapter. * @param extraGas The extra gas that may be needed for execution. */ function _checkAdapterParams(uint16 dstChainId, uint16 pkType, bytes memory adapterParams, uint256 extraGas) internal virtual { OFTCoreStorage storage $ = _getOFTCoreStorage(); if ($.useCustomAdapterParams) { _checkGasLimit(dstChainId, pkType, adapterParams, extraGas); } else { require(adapterParams.length == 0, "OFTCore: _adapterParams must be empty."); } } /** * @dev Debits an amount of tokens from the specified address. * This is an internal function that should be overridden to handle the actual token transfer logic. * * @param from The address from which tokens will be debited. * @param dstChainId The ID of the destination chain. * @param toAddress The encoded destination address on the target chain. * @param amount The amount of tokens to debit. * @return The final amount of tokens that were debited. This allows for potential adjustments. */ function _debitFrom(address from, uint16 dstChainId, bytes memory toAddress, uint256 amount) internal virtual returns (uint256); /** * @dev Credits an amount of tokens to a specific address. * This is an internal function that should be overridden to handle the actual token crediting logic. * * @param srcChainId The ID of the source chain from which the tokens were sent. * @param toAddress The address to which tokens will be credited. * @param amount The amount of tokens to credit. * @return The final amount of tokens that were credited. This allows for potential adjustments. */ function _creditTo(uint16 srcChainId, address toAddress, uint256 amount) internal virtual returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Interface of the IOFT core standard */ interface IOFTCore is IERC165 { /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _amount - amount of the tokens to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParam - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); /** * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` * `_from` the owner of token * `_dstChainId` the destination chain identifier * `_toAddress` can be any size depending on the `dstChainId`. * `_amount` the quantity of tokens in wei * `_refundAddress` the address LayerZero refunds if too much message fee is sent * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable; /** * @dev returns the circulating amount of tokens on current chain */ function circulatingSupply() external view returns (uint); /** * @dev returns the address of the ERC20 token */ function token() external view returns (address); /** * @dev Emitted when `_amount` tokens are moved from the `_sender` to (`_dstChainId`, `_toAddress`) * `_nonce` is the outbound nonce */ event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes _toAddress, uint _amount); /** * @dev Emitted when `_amount` tokens are received from `_srcChainId` into the `_toAddress` on the local chain. * `_nonce` is the inbound nonce. */ event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint _amount); event SetUseCustomAdapterParams(bool _useCustomAdapterParams); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {ExcessivelySafeCall} from "@layerzerolabs/contracts/libraries/ExcessivelySafeCall.sol"; import {LzAppUpgradeable} from "./LzAppUpgradeable.sol"; /** * @title Nonblocking LayerZero Application * @dev This contract extends LzAppUpgradeable and modifies its behavior to be non-blocking. Failed messages are caught * and stored for future retries, ensuring that the message channel remains unblocked. This contract serves as an * abstract base class and should be extended by specific implementations. * * Note: If the `srcAddress` is not configured properly, it will still block the message pathway from (`srcChainId`, * `srcAddress`). */ abstract contract NonblockingLzAppUpgradeable is LzAppUpgradeable { using ExcessivelySafeCall for address; event MessageFailed(uint16 srcChainId, bytes srcAddress, uint64 nonce, bytes payload, bytes reason); event RetryMessageSuccess(uint16 srcChainId, bytes srcAddress, uint64 nonce, bytes32 payloadHash); /// @custom:storage-location erc7201:layerzero.storage.NonblockingLzApp struct NonblockingLzAppStorage { mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) failedMessages; } // keccak256(abi.encode(uint256(keccak256("layerzero.storage.NonblockingLzApp")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant NonblockingLzAppStorageLocation = 0xe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600; function _getNonblockingLzAppStorage() private pure returns (NonblockingLzAppStorage storage $) { // slither-disable-next-line assembly assembly { $.slot := NonblockingLzAppStorageLocation } } /** * @param endpoint The address of the LayerZero endpoint contract. * @custom:oz-upgrades-unsafe-allow constructor */ constructor(address endpoint) LzAppUpgradeable(endpoint) {} /** * @dev Initializes the contract, setting the initial owner and endpoint addresses. * Also chains the initialization process with the base `LzAppUpgradeable` contract. * * Requirements: * - Can only be called during contract initialization. * * @param initialOwner The address that will initially own the contract. */ function __NonblockingLzApp_init(address initialOwner) internal onlyInitializing { __NonblockingLzApp_init_unchained(); __LzApp_init(initialOwner); } function __NonblockingLzApp_init_unchained() internal onlyInitializing {} /** * @dev Retrieves the hash of the payload of a failed message for a given source chain, source address, and nonce. * * @param srcChainId The ID of the source chain where the message originated. * @param srcAddress The address on the source chain where the message originated. * @param nonce The nonce of the failed message. * @return payloadHash The hash of the payload of the failed message. */ function failedMessages(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce) external view returns (bytes32 payloadHash) { NonblockingLzAppStorage storage $ = _getNonblockingLzAppStorage(); return $.failedMessages[srcChainId][srcAddress][nonce]; } /** * @dev Internal function that receives LayerZero messages and attempts to process them in a non-blocking manner. * If processing fails, the message is stored for future retries. * * @param srcChainId The ID of the source chain where the message originated. * @param srcAddress The address on the source chain where the message originated. * @param nonce The nonce of the message. * @param payload The payload of the message. */ function _blockingLzReceive(uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload) internal virtual override { (bool success, bytes memory reason) = address(this).excessivelySafeCall( gasleft(), 150, abi.encodeWithSelector(this.nonblockingLzReceive.selector, srcChainId, srcAddress, nonce, payload) ); // try-catch all errors/exceptions if (!success) { _storeFailedMessage(srcChainId, srcAddress, nonce, payload, reason); } } /** * @dev Internal function to store the details of a failed message for future retries. * * @param srcChainId The ID of the source chain where the message originated. * @param srcAddress The address on the source chain where the message originated. * @param nonce The nonce of the failed message. * @param payload The payload of the failed message. * @param reason The reason for the message's failure. */ function _storeFailedMessage( uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload, bytes memory reason ) internal virtual { NonblockingLzAppStorage storage $ = _getNonblockingLzAppStorage(); $.failedMessages[srcChainId][srcAddress][nonce] = keccak256(payload); emit MessageFailed(srcChainId, srcAddress, nonce, payload, reason); } /** * @dev Public wrapper function for handling incoming LayerZero messages in a non-blocking manner. * It internally calls the `_nonblockingLzReceive` function, which should be overridden in derived contracts. * * Requirements: * - The caller must be the contract itself. * * @param srcChainId The ID of the source chain where the message originated. * @param srcAddress The address on the source chain where the message originated. * @param nonce The nonce of the message. * @param payload The payload of the message. */ function nonblockingLzReceive(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce, bytes calldata payload) public virtual { // only internal transaction require(_msgSender() == address(this), "NonblockingLzApp: caller must be LzApp"); _nonblockingLzReceive(srcChainId, srcAddress, nonce, payload); } /** * @dev Internal function that should be overridden in derived contracts to implement the logic * for processing incoming LayerZero messages in a non-blocking manner. * * @param srcChainId The ID of the source chain where the message originated. * @param srcAddress The address on the source chain where the message originated. * @param nonce The nonce of the message. * @param payload The payload of the message. */ function _nonblockingLzReceive(uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload) internal virtual; /** * @dev Allows for the manual retry of a previously failed message. * * Requirements: * - There must be a stored failed message matching the provided parameters. * - The payload hash must match the stored failed message. * * @param srcChainId The ID of the source chain where the failed message originated. * @param srcAddress The address on the source chain where the failed message originated. * @param nonce The nonce of the failed message. * @param payload The payload of the failed message. */ function retryMessage(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce, bytes calldata payload) public payable virtual { NonblockingLzAppStorage storage $ = _getNonblockingLzAppStorage(); mapping(uint64 => bytes32) storage _failedMessages = $.failedMessages[srcChainId][srcAddress]; // get the payload hash value bytes32 payloadHash = _failedMessages[nonce]; // assert there is message to retry require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message"); require(keccak256(payload) == payloadHash, "NonblockingLzApp: invalid payload"); // clear the stored message _failedMessages[nonce] = bytes32(0); // execute the message. revert if it fails again _nonblockingLzReceive(srcChainId, srcAddress, nonce, payload); emit RetryMessageSuccess(srcChainId, srcAddress, nonce, payloadHash); } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.7.6; library ExcessivelySafeCall { uint constant LOW_28_MASK = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff; /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeCall( address _target, uint _gas, uint16 _maxCopy, bytes memory _calldata ) internal returns (bool, bytes memory) { // set up for assembly call uint _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := call( _gas, // gas _target, // recipient 0, // ether value add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeStaticCall( address _target, uint _gas, uint16 _maxCopy, bytes memory _calldata ) internal view returns (bool, bytes memory) { // set up for assembly call uint _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := staticcall( _gas, // gas _target, // recipient add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /** * @notice Swaps function selectors in encoded contract calls * @dev Allows reuse of encoded calldata for functions with identical * argument types but different names. It simply swaps out the first 4 bytes * for the new selector. This function modifies memory in place, and should * only be used with caution. * @param _newSelector The new 4-byte selector * @param _buf The encoded contract args */ function swapSelector(bytes4 _newSelector, bytes memory _buf) internal pure { require(_buf.length >= 4); uint _mask = LOW_28_MASK; assembly { // load the first word of let _word := mload(add(_buf, 0x20)) // mask out the top 4 bytes // /x _word := and(_word, _mask) _word := or(_newSelector, _word) mstore(add(_buf, 0x20), _word) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {ILayerZeroReceiver} from "@layerzerolabs/contracts/lzApp/interfaces/ILayerZeroReceiver.sol"; import {ILayerZeroUserApplicationConfig} from "@layerzerolabs/contracts/lzApp/interfaces/ILayerZeroUserApplicationConfig.sol"; import {ILayerZeroEndpoint} from "@layerzerolabs/contracts/lzApp/interfaces/ILayerZeroEndpoint.sol"; import {BytesLib} from "@layerzerolabs/contracts/libraries/BytesLib.sol"; /** * @title LzAppUpgradeable * @dev This is a generic implementation of LzReceiver, designed for LayerZero cross-chain communication. * * The contract inherits from `OwnableUpgradeable` and implements `ILayerZeroReceiver` and * `ILayerZeroUserApplicationConfig` interfaces. It provides functionality for setting and managing trusted remote * chains and their corresponding paths, configuring minimum destination gas, payload size limitations, and more. * * The contract uses a custom storage location `LzAppStorage`, which includes various mappings and state variables such * as `trustedRemoteLookup`, `minDstGasLookup`, and `payloadSizeLimitLookup`. * * Events: * - `SetPrecrime(address)`: Emitted when the precrime address is set. * - `SetTrustedRemote(uint16, bytes)`: Emitted when a trusted remote chain is set with its path. * - `SetTrustedRemoteAddress(uint16, bytes)`: Emitted when a trusted remote chain is set with its address. * - `SetMinDstGas(uint16, uint16, uint256)`: Emitted when minimum destination gas is set for a chain and packet type. * * Initialization: * The contract should be initialized by calling `__LzApp_init` function. * * Permissions: * Most administrative tasks require the sender to be the contract's owner. * * Note: * The contract includes the Checks-Effects-Interactions pattern and optimizes for gas-efficiency wherever applicable. */ abstract contract LzAppUpgradeable is OwnableUpgradeable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig { using BytesLib for bytes; // ua can not send payload larger than this by default, but it can be changed by the ua owner uint256 public constant DEFAULT_PAYLOAD_SIZE_LIMIT = 10_000; event SetPrecrime(address precrime); event SetTrustedRemote(uint16 _remoteChainId, bytes _path); event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress); event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint256 _minDstGas); /// @custom:storage-location erc7201:layerzero.storage.LzApp struct LzAppStorage { mapping(uint16 => bytes) trustedRemoteLookup; mapping(uint16 => mapping(uint16 => uint256)) minDstGasLookup; mapping(uint16 => uint256) payloadSizeLimitLookup; address precrime; } // keccak256(abi.encode(uint256(keccak256("layerzero.storage.LzApp")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant LzAppStorageLocation = 0x111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00; function _getLzAppStorage() private pure returns (LzAppStorage storage $) { // slither-disable-next-line assembly assembly { $.slot := LzAppStorageLocation } } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable ILayerZeroEndpoint public immutable lzEndpoint; /** * @param endpoint Address of the LayerZero endpoint contract. * @custom:oz-upgrades-unsafe-allow constructor */ constructor(address endpoint) { lzEndpoint = ILayerZeroEndpoint(endpoint); } /** * @dev Initializes the contract with the given `initialOwner`. * * Requirements: * - The function should only be called during the initialization process. * * @param initialOwner Address of the initial owner of the contract. */ function __LzApp_init(address initialOwner) internal onlyInitializing { __LzApp_init_unchained(); __Ownable_init(initialOwner); } function __LzApp_init_unchained() internal onlyInitializing {} /** * @dev Returns the trusted path for a given remote chain ID. * * @param remoteChainId The ID of the remote chain to query for a trusted path. * @return path Bytes representation of the trusted path for the specified remote chain ID. */ function trustedRemoteLookup(uint16 remoteChainId) external view returns (bytes memory path) { LzAppStorage storage $ = _getLzAppStorage(); path = $.trustedRemoteLookup[remoteChainId]; } /** * @dev Returns the minimum gas required for a given destination chain ID and packet type. * * @param dstChainId The ID of the destination chain to query for a minimum gas limit. * @param packetType The type of packet for which the minimum gas limit is to be fetched. * @return minGas The minimum gas limit required for the specified destination chain ID and packet type. */ function minDstGasLookup(uint16 dstChainId, uint16 packetType) external view returns (uint256 minGas) { LzAppStorage storage $ = _getLzAppStorage(); minGas = $.minDstGasLookup[dstChainId][packetType]; } /** * @dev Returns the payload size limit for a given destination chain ID. * * @param dstChainId The ID of the destination chain to query for a payload size limit. * @return size The maximum allowable payload size in bytes for the specified destination chain ID. */ function payloadSizeLimitLookup(uint16 dstChainId) external view returns (uint256 size) { LzAppStorage storage $ = _getLzAppStorage(); size = $.payloadSizeLimitLookup[dstChainId]; } /** * @dev Returns the address of the precrime contract. * * @return _precrime The address of the precrime contract. */ function precrime() external view returns (address _precrime) { LzAppStorage storage $ = _getLzAppStorage(); _precrime = $.precrime; } /** * @dev Handles incoming LayerZero messages from a source chain. * This function must be called by the LayerZero endpoint and validates the source of the message. * * Requirements: * - Caller must be the LayerZero endpoint. * - Source address must be a trusted remote address. * * @param srcChainId The ID of the source chain from which the message is sent. * @param srcAddress The address on the source chain that is sending the message. * @param nonce A unique identifier for the message. * @param payload The actual data payload of the message. */ function lzReceive(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce, bytes calldata payload) public virtual override { LzAppStorage storage $ = _getLzAppStorage(); // lzReceive must be called by the endpoint for security require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = $.trustedRemoteLookup[srcChainId]; // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from // untrusted remote. require( srcAddress.length == trustedRemote.length && trustedRemote.length != 0 && keccak256(srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract" ); _blockingLzReceive(srcChainId, srcAddress, nonce, payload); } /** * @dev Internal function that handles incoming LayerZero messages in a blocking manner. * This is an abstract function and should be implemented by derived contracts. * * @param srcChainId The ID of the source chain from which the message is sent. * @param srcAddress The address on the source chain that is sending the message. * @param nonce A unique identifier for the message. * @param payload The actual data payload of the message. */ function _blockingLzReceive(uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload) internal virtual; /** * @dev Internal function to send a LayerZero message to a destination chain. * It performs a series of validations before sending the message. * * Requirements: * - Destination chain must be a trusted remote. * - Payload size must be within the configured limit. * * @param dstChainId The ID of the destination chain. * @param payload The actual data payload to be sent. * @param refundAddress The address to which any refunds should be sent. * @param zroPaymentAddress The address for the ZRO token payment. * @param adapterParams Additional parameters required for the adapter. * @param nativeFee The native fee to be sent along with the message. */ function _lzSend( uint16 dstChainId, bytes memory payload, address payable refundAddress, address zroPaymentAddress, bytes memory adapterParams, uint256 nativeFee ) internal virtual { LzAppStorage storage $ = _getLzAppStorage(); bytes memory trustedRemote = $.trustedRemoteLookup[dstChainId]; require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source"); _checkPayloadSize(dstChainId, payload.length); lzEndpoint.send{value: nativeFee}( dstChainId, trustedRemote, payload, refundAddress, zroPaymentAddress, adapterParams ); } /** * @dev Internal function to validate if the provided gas limit meets the minimum requirement for a given packet * type and destination chain. * * Requirements: * - The minimum destination gas limit must be set for the given packet type and destination chain. * - Provided gas limit should be greater than or equal to the sum of the minimum gas limit and any extra gas. * * @param dstChainId The ID of the destination chain. * @param packetType The type of the packet being sent. * @param adapterParams Additional parameters required for the adapter. * @param extraGas Extra gas to be added to the minimum required gas. */ function _checkGasLimit(uint16 dstChainId, uint16 packetType, bytes memory adapterParams, uint256 extraGas) internal view virtual { LzAppStorage storage $ = _getLzAppStorage(); uint256 providedGasLimit = _getGasLimit(adapterParams); uint256 minGasLimit = $.minDstGasLookup[dstChainId][packetType]; require(minGasLimit != 0, "LzApp: minGasLimit not set"); require(providedGasLimit >= minGasLimit + extraGas, "LzApp: gas limit is too low"); } /** * @dev Internal function to extract the gas limit from the adapter parameters. * * Requirements: * - The `adapterParams` must be at least 34 bytes long to contain the gas limit. * * @param _adapterParams The adapter parameters from which the gas limit is to be extracted. * @return gasLimit The extracted gas limit. */ function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint256 gasLimit) { require(_adapterParams.length >= 34, "LzApp: invalid adapterParams"); // slither-disable-next-line assembly assembly { gasLimit := mload(add(_adapterParams, 34)) } } /** * @dev Internal function to validate the size of the payload against the configured limit for a given destination * chain. * * Requirements: * - Payload size must be less than or equal to the configured size limit for the given destination chain. * * @param _dstChainId The ID of the destination chain. * @param _payloadSize The size of the payload in bytes. */ function _checkPayloadSize(uint16 _dstChainId, uint256 _payloadSize) internal view virtual { LzAppStorage storage $ = _getLzAppStorage(); uint256 payloadSizeLimit = $.payloadSizeLimitLookup[_dstChainId]; if (payloadSizeLimit == 0) { // use default if not set payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT; } require(_payloadSize <= payloadSizeLimit, "LzApp: payload size is too large"); } /** * @dev Retrieves the configuration of the LayerZero user application for a given version, chain ID, and config * type. * * @param version The version for which the configuration is to be fetched. * @param chainId The ID of the chain for which the configuration is needed. * @param configType The type of the configuration to be retrieved. * @return The bytes representation of the configuration. */ function getConfig(uint16 version, uint16 chainId, address, uint256 configType) external view returns (bytes memory) { return lzEndpoint.getConfig(version, chainId, address(this), configType); } /** * @dev Sets the configuration of the LayerZero user application for a given version, chain ID, and config type. * * Requirements: * - Only the owner can set the configuration. * * @param version The version for which the configuration is to be set. * @param chainId The ID of the chain for which the configuration is being set. * @param configType The type of the configuration to be set. * @param config The actual configuration data in bytes format. */ function setConfig(uint16 version, uint16 chainId, uint256 configType, bytes calldata config) external override onlyOwner { lzEndpoint.setConfig(version, chainId, configType, config); } /** * @dev Sets the version to be used for sending LayerZero messages. * * Requirements: * - Only the owner can set the send version. * * @param version The version to be set for sending messages. */ function setSendVersion(uint16 version) external override onlyOwner { lzEndpoint.setSendVersion(version); } /** * @dev Sets the version to be used for receiving LayerZero messages. * * Requirements: * - Only the owner can set the receive version. * * @param version The version to be set for receiving messages. */ function setReceiveVersion(uint16 version) external override onlyOwner { lzEndpoint.setReceiveVersion(version); } /** * @dev Resumes the reception of LayerZero messages from a specific source chain and address. * * Requirements: * - Only the owner can force the resumption of message reception. * * @param srcChainId The ID of the source chain from which message reception is to be resumed. * @param srcAddress The address on the source chain for which message reception is to be resumed. */ function forceResumeReceive(uint16 srcChainId, bytes calldata srcAddress) external override onlyOwner { lzEndpoint.forceResumeReceive(srcChainId, srcAddress); } /** * @dev Sets the trusted path for cross-chain communication with a specified remote chain. * * Requirements: * - Only the owner can set the trusted path. * * @param remoteChainId The ID of the remote chain for which the trusted path is being set. * @param path The trusted path encoded as bytes. */ function setTrustedRemote(uint16 remoteChainId, bytes calldata path) external onlyOwner { LzAppStorage storage $ = _getLzAppStorage(); $.trustedRemoteLookup[remoteChainId] = path; emit SetTrustedRemote(remoteChainId, path); } /** * @dev Sets the trusted remote address for cross-chain communication with a specified remote chain. * The function also automatically appends the contract's own address to the path. * * Requirements: * - Only the owner can set the trusted remote address. * * @param remoteChainId The ID of the remote chain for which the trusted address is being set. * @param remoteAddress The trusted remote address encoded as bytes. */ function setTrustedRemoteAddress(uint16 remoteChainId, bytes calldata remoteAddress) external onlyOwner { LzAppStorage storage $ = _getLzAppStorage(); $.trustedRemoteLookup[remoteChainId] = abi.encodePacked(remoteAddress, address(this)); emit SetTrustedRemoteAddress(remoteChainId, remoteAddress); } /** * @dev Retrieves the trusted remote address for a given remote chain. * * Requirements: * - A trusted path record must exist for the specified remote chain. * * @param remoteChainId The ID of the remote chain for which the trusted address is needed. * @return The trusted remote address encoded as bytes. */ function getTrustedRemoteAddress(uint16 remoteChainId) external view returns (bytes memory) { LzAppStorage storage $ = _getLzAppStorage(); bytes memory path = $.trustedRemoteLookup[remoteChainId]; require(path.length != 0, "LzApp: no trusted path record"); return path.slice(0, path.length - 20); // the last 20 bytes should be address(this) } /** * @dev Sets the "Precrime" address, which could be an address for handling fraudulent activities or other specific * behaviors. * * Requirements: * - Only the owner can set the Precrime address. * * @param _precrime The address to be set as Precrime. */ function setPrecrime(address _precrime) external onlyOwner { LzAppStorage storage $ = _getLzAppStorage(); $.precrime = _precrime; emit SetPrecrime(_precrime); } /** * @dev Sets the minimum required gas for a specific packet type and destination chain. * * Requirements: * - Only the owner can set the minimum destination gas. * * @param dstChainId The ID of the destination chain for which the minimum gas is being set. * @param packetType The type of the packet for which the minimum gas is being set. * @param minGas The minimum required gas in units. */ function setMinDstGas(uint16 dstChainId, uint16 packetType, uint256 minGas) external onlyOwner { LzAppStorage storage $ = _getLzAppStorage(); $.minDstGasLookup[dstChainId][packetType] = minGas; emit SetMinDstGas(dstChainId, packetType, minGas); } /** * @dev Sets the payload size limit for a specific destination chain. * * Requirements: * - Only the owner can set the payload size limit. * * @param dstChainId The ID of the destination chain for which the payload size limit is being set. * @param size The size limit in bytes. */ function setPayloadSizeLimit(uint16 dstChainId, uint256 size) external onlyOwner { LzAppStorage storage $ = _getLzAppStorage(); $.payloadSizeLimitLookup[dstChainId] = size; } /** * @dev Checks whether a given source chain and address are trusted for receiving LayerZero messages. * * @param srcChainId The ID of the source chain to be checked. * @param srcAddress The address on the source chain to be verified. * @return A boolean indicating whether the source chain and address are trusted. */ function isTrustedRemote(uint16 srcChainId, bytes calldata srcAddress) external view returns (bool) { LzAppStorage storage $ = _getLzAppStorage(); bytes memory trustedSource = $.trustedRemoteLookup[srcChainId]; return keccak256(trustedSource) == keccak256(srcAddress); } }
// 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 pragma solidity >=0.5.0; interface ILayerZeroReceiver { // @notice LayerZero endpoint will invoke this function to deliver the message on the destination // @param _srcChainId - the source endpoint identifier // @param _srcAddress - the source sending contract address from the source chain // @param _nonce - the ordered message nonce // @param _payload - the signed payload is the UA bytes has encoded to be sent function lzReceive( uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface ILayerZeroUserApplicationConfig { // @notice set the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _configType - type of configuration. every messaging library has its own convention. // @param _config - configuration in the bytes. can encode arbitrary content. function setConfig( uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config ) external; // @notice set the send() LayerZero messaging library version to _version // @param _version - new messaging library version function setSendVersion(uint16 _version) external; // @notice set the lzReceive() LayerZero messaging library version to _version // @param _version - new messaging library version function setReceiveVersion(uint16 _version) external; // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload // @param _srcChainId - the chainId of the source chain // @param _srcAddress - the contract address of the source contract at the source chain function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./ILayerZeroUserApplicationConfig.sol"; interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig { // @notice send a LayerZero message to the specified address at a LayerZero endpoint. // @param _dstChainId - the destination chain identifier // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains // @param _payload - a custom bytes payload to send to the destination contract // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination function send( uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) external payable; // @notice used by the messaging library to publish verified payload // @param _srcChainId - the source chain identifier // @param _srcAddress - the source contract (as bytes) at the source chain // @param _dstAddress - the address on destination chain // @param _nonce - the unbound message ordering nonce // @param _gasLimit - the gas limit for external contract execution // @param _payload - verified payload to send to the destination contract function receivePayload( uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload ) external; // @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64); // @notice get the outboundNonce from this source chain which, consequently, is always an EVM // @param _srcAddress - the source chain contract address function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64); // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery // @param _dstChainId - the destination chain identifier // @param _userApplication - the user app address on this EVM chain // @param _payload - the custom message to send over LayerZero // @param _payInZRO - if false, user app pays the protocol fee in native token // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain function estimateFees( uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam ) external view returns (uint nativeFee, uint zroFee); // @notice get this Endpoint's immutable source identifier function getChainId() external view returns (uint16); // @notice the interface to retry failed message on this Endpoint destination // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address // @param _payload - the payload to be retried function retryPayload( uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload ) external; // @notice query if any STORED payload (message blocking) at the endpoint. // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool); // @notice query if the _libraryAddress is valid for sending msgs. // @param _userApplication - the user app address on this EVM chain function getSendLibraryAddress(address _userApplication) external view returns (address); // @notice query if the _libraryAddress is valid for receiving msgs. // @param _userApplication - the user app address on this EVM chain function getReceiveLibraryAddress(address _userApplication) external view returns (address); // @notice query if the non-reentrancy guard for send() is on // @return true if the guard is on. false otherwise function isSendingPayload() external view returns (bool); // @notice query if the non-reentrancy guard for receive() is on // @return true if the guard is on. false otherwise function isReceivingPayload() external view returns (bool); // @notice get the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _userApplication - the contract address of the user application // @param _configType - type of configuration. every messaging library has its own convention. function getConfig( uint16 _version, uint16 _chainId, address _userApplication, uint _configType ) external view returns (bytes memory); // @notice get the send() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getSendVersion(address _userApplication) external view returns (uint16); // @notice get the lzReceive() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getReceiveVersion(address _userApplication) external view returns (uint16); }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "@tangible/=lib/tangible-foundation-contracts/src/", "@layerzerolabs/contracts-upgradeable/=lib/tangible-foundation-contracts/src/layerzero/", "@layerzerolabs/contracts/=lib/tangible-foundation-contracts/lib/layerzerolabs/contracts/", "@openzeppelin/contracts-upgradeable/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/", "erc4626-tests/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "layerzerolabs/=lib/tangible-foundation-contracts/lib/layerzerolabs/contracts/", "openzeppelin-contracts-upgradeable/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/", "tangible-foundation-contracts/=lib/tangible-foundation-contracts/src/" ], "optimizer": { "enabled": true, "runs": 10000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"mainChainId","type":"uint256"},{"internalType":"address","name":"endpoint","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AmountExceedsBalance","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"CannotBridgeWhenOptedOut","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidZeroAddress","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NotAuthorized","type":"error"},{"inputs":[],"name":"NotInitializing","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":[],"name":"RebaseOverflow","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SupplyOverflow","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"UnsupportedChain","type":"error"},{"inputs":[],"name":"ValueUnchanged","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"bytes","name":"payload","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"reason","type":"bytes"}],"name":"MessageFailed","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":true,"internalType":"address","name":"account","type":"address"}],"name":"RebaseDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"RebaseEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"manager","type":"address"}],"name":"RebaseIndexManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"updatedBy","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalSupplyBefore","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalSupplyAfter","type":"uint256"}],"name":"RebaseIndexUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"ReceiveFromChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"name":"RetryMessageSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"bytes","name":"_toAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"SendToChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"_type","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_minDstGas","type":"uint256"}],"name":"SetMinDstGas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"precrime","type":"address"}],"name":"SetPrecrime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_path","type":"bytes"}],"name":"SetTrustedRemote","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"SetTrustedRemoteAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_useCustomAdapterParams","type":"bool"}],"name":"SetUseCustomAdapterParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_PAYLOAD_SIZE_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NO_EXTRA_GAS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PT_SEND","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNDERLYING","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"circulatingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"disable","type":"bool"}],"name":"disableRebase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"bytes","name":"toAddress","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"useZro","type":"bool"},{"internalType":"bytes","name":"adapterParams","type":"bytes"}],"name":"estimateSendFee","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"zroFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"name":"failedMessages","outputs":[{"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"}],"name":"forceResumeReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"configType","type":"uint256"}],"name":"getConfig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"}],"name":"getTrustedRemoteAddress","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"indexManager","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isMainChain","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"}],"name":"isTrustedRemote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lzEndpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint16","name":"packetType","type":"uint16"}],"name":"minDstGasLookup","outputs":[{"internalType":"uint256","name":"minGas","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"nonblockingLzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"optedOut","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"}],"name":"payloadSizeLimitLookup","outputs":[{"internalType":"uint256","name":"size","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"precrime","outputs":[{"internalType":"address","name":"_precrime","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebaseIndex","outputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebaseIndexManager","outputs":[{"internalType":"address","name":"_rebaseIndexManager","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refreshRebaseIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"retryMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"bytes","name":"toAddress","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"refundAddress","type":"address"},{"internalType":"address","name":"zroPaymentAddress","type":"address"},{"internalType":"bytes","name":"adapterParams","type":"bytes"}],"name":"sendFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint256","name":"configType","type":"uint256"},{"internalType":"bytes","name":"config","type":"bytes"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint16","name":"packetType","type":"uint16"},{"internalType":"uint256","name":"minGas","type":"uint256"}],"name":"setMinDstGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint256","name":"size","type":"uint256"}],"name":"setPayloadSizeLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_precrime","type":"address"}],"name":"setPrecrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"setRebaseIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"manager","type":"address"}],"name":"setRebaseIndexManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"setReceiveVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"setSendVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"},{"internalType":"bytes","name":"path","type":"bytes"}],"name":"setTrustedRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"},{"internalType":"bytes","name":"remoteAddress","type":"bytes"}],"name":"setTrustedRemoteAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"useCustomAdapterParams","type":"bool"}],"name":"setUseCustomAdapterParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"}],"name":"trustedRemoteLookup","outputs":[{"internalType":"bytes","name":"path","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"expectedBalance","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"withdrawExcessAmount","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
61010034620001d857601f6200616738819003918201601f19168301926001600160401b0392909183851183861017620001dd578160609284926040978852833981010312620001d8576200005481620001f3565b602082015190916001600160a01b039062000071908601620001f3565b16608052461460a0523060c05260e0527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a009081549060ff82851c16620001c757808083160362000182575b8351615f5e90816200020982396080518181816104730152818161082c01528181610a8001528181610df001528181611173015281816124b20152818161286b01528181612e5a0152613d7c015260a051818181610b1401528181611066015281816117e301528181611ac7015281816120b9015281816124ee015281816142c801528181614577015281816149d101528181615c250152615dcf015260c0518181816113f2015261185e015260e0518181816110fb015281816127ea0152615e2a0152f35b6001600160401b0319909116811790915581519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a1388080620000bc565b835163f92ee8a960e01b8152600490fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b0382168203620001d85756fe6080604052600436101561001257600080fd5b60003560e01c80621d3567146103ac57806301ffc9a7146103a757806306fdde03146103a257806307e0db171461039d578063095ea7b3146103985780630df374831461039357806310ddb1371461038e57806311a4e7861461038957806318160ddd1461031157806323b872dd146103845780632a205e3d1461037f578063313ce5671461037a5780633d8b38f6146103755780633d96cedf146103705780633f1f4fa41461036b57806340c10f191461036657806342d65a8d14610361578063447705151461035757806347e1b3721461035c5780634c42899a146103575780634f1ef28614610352578063519056361461034d57806351c977601461034857806352d1902d146103435780635b8c41e61461033e57806366ad5c8a146103395780636cae7d0f1461033457806370a082311461032f578063715018a61461032a5780637533d7881461032557806380d1dfa8146103205780638cfd8f5c1461031b5780638da5cb5b146103165780639358928b14610311578063950c8a741461030c57806395d89b41146103075780639dc29fac146103025780639f38369a146102fd578063a6c3d165146102f8578063a9059cbb146102f3578063aa888223146102ee578063ad3cb1cc146102e9578063b353aaa7146102e4578063b834f6fb146102df578063baf3292d146102da578063c4461834146102d5578063c4d66de8146102d0578063c5d664c6146102cb578063cbed8b9c146102c6578063d1deba1f146102c1578063dd62ed3e146102bc578063df2a5b3b146102b7578063eab45d9c146102b2578063eb8d72b7146102ad578063f2fde38b146102a8578063f5ecbdbc146102a3578063f672ade41461029e5763fc0c546a1461029957600080fd5b612f02565b612ebc565b612dcf565b612da2565b612c37565b612b98565b612ae8565b612a7e565b612914565b61280e565b6127ca565b6125d3565b6125b6565b612513565b6124d6565b612492565b612434565b61241b565b6123f1565b612250565b61218f565b612095565b611fcd565b611f87565b610c91565b611f41565b611ec9565b611d8c565b611d16565b611c82565b611c5b565b611bf3565b6119a1565b6118d8565b611843565b611798565b61159c565b61139d565b6111eb565b611207565b611151565b611042565b610fe4565b610f3a565b610ebf565b610e6a565b610d09565b610cb4565b610af0565b610a4e565b6109ec565b6108c2565b6107fa565b6106d3565b610588565b610456565b61ffff8116036103bd57565b600080fd5b9181601f840112156103bd5782359167ffffffffffffffff83116103bd57602083818601950101116103bd57565b9060806003198301126103bd57600435610409816103b1565b9167ffffffffffffffff906024358281116103bd578161042b916004016103c2565b9390939260443581811681036103bd57926064359182116103bd57610452916004016103c2565b9091565b346103bd57610464366103f0565b91929493906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633036105445761050761050f92610515976105006104e66104e18a61ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00602052604060002090565b613465565b805190818414918261053a575b5081610517575b50613480565b3691611366565b923691611366565b9261386d565b005b9050610524368486611366565b60208151910120906020815191012014386104fa565b15159150386104f3565b606460405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c657200006044820152fd5b346103bd5760206003193601126103bd576004357fffffffff0000000000000000000000000000000000000000000000000000000081168091036103bd578060209115908115610642575b81156105e5575b506040519015158152f35b7f14e4ceea00000000000000000000000000000000000000000000000000000000811491508115610618575b50386105da565b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501438610611565b7f36372b0700000000000000000000000000000000000000000000000000000000811491506105d3565b60009103126103bd57565b60005b83811061068a5750506000910152565b818101518382015260200161067a565b90601f19601f6020936106b881518092818752878088019101610677565b0116010190565b9060206106d092818152019061069a565b90565b346103bd576000806003193601126107f75760405190807f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace039081549061071882613051565b808652926001928084169081156107ac5750600114610752575b61074e8661074281880382611318565b604051918291826106bf565b0390f35b815292507f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab05b8284106107945750505081016020016107428261074e38610732565b80546020858701810191909152909301928101610778565b87965061074e979450602093506107429592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b820101929338610732565b80fd5b346103bd57600060206003193601126107f757600435610819816103b1565b610821612f1d565b816001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691823b156108ad57602461ffff918360405195869485937f07e0db170000000000000000000000000000000000000000000000000000000085521660048401525af180156108a85761089c575080f35b6108a590611273565b80f35b613045565b5080fd5b6001600160a01b038116036103bd57565b346103bd5760406003193601126103bd576004356108df816108b1565b60243533156109bb576001600160a01b03821691821561098a57610952829161093a336001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b906001600160a01b0316600052602052604060002090565b556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b60246040517f94280d6200000000000000000000000000000000000000000000000000000000815260006004820152fd5b60246040517fe602df0500000000000000000000000000000000000000000000000000000000815260006004820152fd5b346103bd5760406003193601126103bd57600435610a09816103b1565b610a11612f1d565b610a4b6024359161ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604060002090565b55005b346103bd57600060206003193601126107f757600435610a6d816103b1565b610a75612f1d565b816001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691823b156108ad57602461ffff918360405195869485937f10ddb1370000000000000000000000000000000000000000000000000000000085521660048401525af180156108a85761089c575080f35b346103bd5760606003193601126103bd57600435604435610b10816108b1565b60017f0000000000000000000000000000000000000000000000000000000000000000151503610c61576001600160a01b03807f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00541633141580610c32575b610c0257811615610bd85761051591610b86615dcd565b610bb47f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b005460243514614cdb565b610bbd306145b9565b610bc8828211614cdb565b610bd0615dcd565b03903061586a565b60046040517ff6b2911f000000000000000000000000000000000000000000000000000000008152fd5b60246040517f4a0bfec1000000000000000000000000000000000000000000000000000000008152336004820152fd5b5060ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615610b6f565b60246040517fc3a55c98000000000000000000000000000000000000000000000000000000008152466004820152fd5b346103bd5760006003193601126103bd576020610cac6146a6565b604051908152f35b346103bd5760606003193601126103bd57610cf4600435610cd4816108b1565b602435610ce0816108b1565b60443591610cef833383613183565b613159565b602060405160018152f35b801515036103bd57565b346103bd5760a06003193601126103bd57600435610d26816103b1565b67ffffffffffffffff906024358281116103bd57610d489036906004016103c2565b9060643592610d5684610cff565b6084359485116103bd57610de4610d74610daf9636906004016103c2565b906040978896610d9988519788926000602085015260608b8501526080840191613559565b604435606083015203601f198101875286611318565b855196879586957f40a7bb10000000000000000000000000000000000000000000000000000000008752309060048801613b22565b03816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa9182156108a8576000918293610e35575b50519081526020810191909152604090f35b81610e5b92945061074e93503d8511610e63575b610e538183611318565b810190613b0c565b929091610e23565b503d610e49565b346103bd5760006003193601126103bd57602060405160128152f35b9060406003198301126103bd57600435610e9f816103b1565b916024359067ffffffffffffffff82116103bd57610452916004016103c2565b346103bd57602061ffff610f2b610ed536610e86565b939091166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b008452610f16610f1d6040600020604051928380926130a4565b0382611318565b848151910120923691611366565b82815191012014604051908152f35b346103bd5760206003193601126103bd576001600160a01b03600435610f5f816108b1565b610f67612f1d565b168015610bd85760207f2f2bf8dfa9db3b9a1760050db61b562dd190c82161ca91a2456aceb26ac2df45917f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00817fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055604051908152a1005b346103bd5760206003193601126103bd576020611039600435611006816103b1565b61ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604060002090565b54604051908152f35b346103bd5760406003193601126103bd5760043561105f816108b1565b60243560017f0000000000000000000000000000000000000000000000000000000000000000151503610c61576001600160a01b0380831615611120576110b182610515946110ac615dcd565b61530d565b604051917f23b872dd0000000000000000000000000000000000000000000000000000000060208401523360248401523060448401526064830152606482526110f9826112a8565b7f000000000000000000000000000000000000000000000000000000000000000016614c46565b60246040517fec442f0500000000000000000000000000000000000000000000000000000000815260006004820152fd5b346103bd5761115f36610e86565b9190611169612f1d565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691823b156103bd57604051928380927f42d65a8d000000000000000000000000000000000000000000000000000000008252816111d9600098899788946004850161357a565b03925af180156108a85761089c575080f35b346103bd5760006003193601126103bd57602060405160008152f35b346103bd5760006003193601126103bd5760207f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054604051908152f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff811161128757604052565b611244565b6060810190811067ffffffffffffffff82111761128757604052565b60a0810190811067ffffffffffffffff82111761128757604052565b6080810190811067ffffffffffffffff82111761128757604052565b6040810190811067ffffffffffffffff82111761128757604052565b60c0810190811067ffffffffffffffff82111761128757604052565b90601f601f19910116810190811067ffffffffffffffff82111761128757604052565b604051906113488261128c565b565b67ffffffffffffffff811161128757601f01601f191660200190565b9291926113728261134a565b916113806040519384611318565b8294818452818301116103bd578281602093846000960137010152565b60406003193601126103bd5760048035906113b7826108b1565b60243567ffffffffffffffff81116103bd57366023820112156103bd576113e79036906024818501359101611366565b6001600160a01b03807f00000000000000000000000000000000000000000000000000000000000000001680301490811561156e575b5061154557906020839261142f612f1d565b604051938480927f52d1902d00000000000000000000000000000000000000000000000000000000825288165afa60009281611515575b506114ad5750506040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0390921690820190815281906020010390fd5b83837f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc84036114e0576105158383613288565b6040517faa1d49a400000000000000000000000000000000000000000000000000000000815290810184815281906020010390fd5b61153791935060203d811161153e575b61152f8183611318565b810190613036565b9138611466565b503d611525565b826040517fe07c8dba000000000000000000000000000000000000000000000000000000008152fd5b9050817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc541614153861141d565b60e06003193601126103bd576004356115b4816108b1565b6024356115c0816103b1565b67ffffffffffffffff6044358181116103bd576115e19036906004016103c2565b9091608435906115f0826108b1565b60a435926115fd846108b1565b60c4359182116103bd5761162561161b61162d9336906004016103c2565b9690923691611366565b943691611366565b9260ff61166c876001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b541661175e57611757610515966116838688613efe565b611749611692606435836142a7565b886116f77f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00547fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b50054936116e361133b565b9481865282602087015260408601526141a7565b7f39a4c66499bcf4b56d79f0dde8ed7a9d4925a0df55825206b2b8531e202be0d06040518061173661ffff6001600160a01b038a169616948b83613c4d565b0390a36040519485933360208601613c69565b03601f198101835282611318565b3494613d11565b6040517f63b4968b0000000000000000000000000000000000000000000000000000000081526001600160a01b0387166004820152602490fd5b346103bd5760406003193601126103bd576001600160a01b037f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00541633141580611814575b610c02577f0000000000000000000000000000000000000000000000000000000000000000610c6157610515602435600435614372565b5060ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c16156117dd565b346103bd5760006003193601126103bd576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036118ae5760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b60046040517fe07c8dba000000000000000000000000000000000000000000000000000000008152fd5b346103bd5760606003193601126103bd576004356118f5816103b1565b67ffffffffffffffff6024358181116103bd576119169036906004016103c2565b60449291923591821682036103bd5760206119909361196561074e9661ffff166000527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600602052604060002090565b8360405194859384378201908152030190209067ffffffffffffffff16600052602052604060002090565b546040519081529081906020820190565b346103bd576119af366103f0565b9392909150303303611b89576119ca92610507913691611366565b602081019161ffff918284511615600014611b455780518101918183039460e086126103bd576119fa90516103b1565b604082015193611a09856108b1565b606083015193611a18856108b1565b608084015167ffffffffffffffff81116103bd57611a617fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809160208060609501918801016134f1565b9701126103bd57611b1a7fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf95611af9611b0398611af3611b309660405198611aa88a61128c565b60a08101518a5260e060c0820151918260208d015201518060408c01527f000000000000000000000000000000000000000000000000000000000000000015611b35575b505061431b565b5061431b565b9788955186614546565b9788916001600160a01b038080991691168b6144be565b5060405193849316961694829190602083019252565b0390a3005b611b3e91614372565b3880611aec565b606460405162461bcd60e51b815260206004820152601c60248201527f4f4654436f72653a20756e6b6e6f776e207061636b65742074797065000000006044820152fd5b608460405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d75737420626560448201527f204c7a41707000000000000000000000000000000000000000000000000000006064820152fd5b346103bd5760206003193601126103bd57602060ff611c4f600435611c17816108b1565b6001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b54166040519015158152f35b346103bd5760206003193601126103bd576020610cac600435611c7d816108b1565b6145b9565b346103bd576000806003193601126107f757611c9c612f1d565b806001600160a01b037f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993008054907fffffffffffffffffffffffff000000000000000000000000000000000000000082169055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346103bd5760206003193601126103bd5761ffff600435611d36816103b1565b166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b0060205261074e610f16611d786040600020604051928380926130a4565b60405191829160208352602083019061069a565b346103bd5760406003193601126103bd57600435611da9816108b1565b602435611db581610cff565b6001600160a01b03821633141580611e80575b611e4f57611e12611e0b836001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b5460ff1690565b151581151514611e255761051591614d11565b60046040517fdf82d43b000000000000000000000000000000000000000000000000000000008152fd5b6040517f4a0bfec1000000000000000000000000000000000000000000000000000000008152336004820152602490fd5b50611ec1611eb57f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00546001600160a01b031690565b6001600160a01b031690565b331415611dc8565b346103bd5760406003193601126103bd576020611039600435611eeb816103b1565b611f2e60243591611efb836103b1565b61ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602052604060002090565b9061ffff16600052602052604060002090565b346103bd5760006003193601126103bd5760206001600160a01b037f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b346103bd5760006003193601126103bd5760206001600160a01b037f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b035416604051908152f35b346103bd576000806003193601126107f75760405190807f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace049081549061201282613051565b808652926001928084169081156107ac575060011461203b5761074e8661074281880382611318565b815292507f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa5b82841061207d5750505081016020016107428261074e38610732565b80546020858701810191909152909301928101612061565b346103bd5760406003193601126103bd576004356120b2816108b1565b60243560017f0000000000000000000000000000000000000000000000000000000000000000151503610c61576001600160a01b0380831633810361217f575b1561214e5761210c8261051594612107615dcd565b6155dd565b604051917fa9059cbb0000000000000000000000000000000000000000000000000000000060208401523360248401526044830152604482526110f9826112c4565b60246040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260006004820152fd5b61218a833386613183565b6120f2565b346103bd5760206003193601126103bd5761ffff6004356121af816103b1565b166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00602052610f166121ee6040600020604051928380926130a4565b80511561220c576107428161220661074e935161370a565b906137ed565b606460405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f72640000006044820152fd5b346103bd5761225e36610e86565b9190612268612f1d565b6040519160208483828601376122936034858781013060601b85820152036014810187520185611318565b60009361ffff831685527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b008252604085209181519167ffffffffffffffff8311611287576122eb836122e58654613051565b866136a1565b81601f841160011461235b5750918061234a94928899947f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce9992612350575b50506000198260011b9260031b1c19161790555b6040519384938461357a565b0390a180f35b01519050388061232a565b9190601f19841661237186600052602060002090565b9389905b8282106123d95750509260019285927f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce9a9b9661234a9896106123c0575b505050811b01905561233e565b015160001960f88460031b161c191690553880806123b3565b80600186978294978701518155019601940190612375565b346103bd5760406003193601126103bd57610cf4600435612411816108b1565b6024359033613159565b346103bd5760006003193601126103bd57610515615dcd565b346103bd5760006003193601126103bd5761074e604051612454816112e0565b600581527f352e302e30000000000000000000000000000000000000000000000000000000602082015260405191829160208352602083019061069a565b346103bd5760006003193601126103bd5760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346103bd5760006003193601126103bd5760206040517f000000000000000000000000000000000000000000000000000000000000000015158152f35b346103bd5760206003193601126103bd577f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b60206001600160a01b0360043561255b816108b1565b612563612f1d565b167f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b03817fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055604051908152a1005b346103bd5760006003193601126103bd5760206040516127108152f35b346103bd5760206003193601126103bd576004356125f0816108b1565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549067ffffffffffffffff60ff8360401c16159216801590816127c2575b60011490816127b8575b1590816127af575b50612785576126a3908261269a7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0060017fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000825416179055565b6127295761485f565b6126a957005b6126f57ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff8154169055565b604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29080602081015b0390a1005b6127807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00680100000000000000007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff825416179055565b61485f565b60046040517ff92ee8a9000000000000000000000000000000000000000000000000000000008152fd5b90501538612641565b303b159150612639565b83915061262f565b346103bd5760006003193601126103bd5760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346103bd5760806003193601126103bd5760043561282b816103b1565b602435612837816103b1565b60643567ffffffffffffffff81116103bd576128579036906004016103c2565b9092612861612f1d565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690813b156103bd57600080946128f1604051978896879586947fcbed8b9c00000000000000000000000000000000000000000000000000000000865261ffff80921660048701521660248501526044356044850152608060648501526084840191613559565b03925af180156108a85761290157005b8061290e61051592611273565b8061066c565b61291d366103f0565b94929161ffff84166000527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d860060205260406000206020604051809286898337868201908152030190209261298582859067ffffffffffffffff16600052602052604060002090565b54928315612a14577fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e597612a01612a089260006129f5876127249a6129dc8b6129cf368a89611366565b6020815191012014613a63565b9067ffffffffffffffff16600052602052604060002090565b5561050736868c611366565b9087613b69565b60405195869586613ad4565b608460405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201527f61676500000000000000000000000000000000000000000000000000000000006064820152fd5b346103bd5760406003193601126103bd576020611039600435612aa0816108b1565b61093a60243591612ab0836108b1565b6001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b346103bd5760606003193601126103bd577f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac06060600435612b28816103b1565b60243590612b35826103b1565b60443590612b41612f1d565b81612b7d84611f2e8461ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602052604060002090565b556040519261ffff80921684521660208301526040820152a1005b346103bd5760206003193601126103bd577f1584ad594a70cbe1e6515592e1272a987d922b097ead875069cebe8b40c004a46020600435612bd881610cff565b612be0612f1d565b15157f822492242235517548c4a8cf040400e3c0daf5b82af652ed16dce4fa3ae728007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541660ff8316179055604051908152a1005b346103bd57612c4536610e86565b9190612c4f612f1d565b60009161ffff8116835260207f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b008152604084209067ffffffffffffffff861161128757612ca686612ca08454613051565b846136a1565b8490601f8711600114612d0e57509461234a918186977ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab9791612d03575b508260011b906000198460031b1c19161790556040519384938461357a565b905085013538612ce4565b90601f198716612d2384600052602060002090565b9287905b828210612d8a5750509161234a9391887ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab98999410612d70575b5050600182811b01905561233e565b60001960f88560031b161c19908701351690553880612d61565b80600185968294968b01358155019501930190612d27565b346103bd5760206003193601126103bd57610515600435612dc2816108b1565b612dca612f1d565b612f80565b346103bd5760806003193601126103bd57600435612dec816103b1565b60243590612df9826103b1565b612e046044356108b1565b604051917ff5ecbdbc00000000000000000000000000000000000000000000000000000000835261ffff809216600484015216602482015230604482015260643560648201526000816084816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa80156108a85761074e91600091612e9b575b50604051918291826106bf565b612eb6913d8091833e612eae8183611318565b810190613533565b38612e8e565b346103bd5760006003193601126103bd5760206001600160a01b037f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd005416604051908152f35b346103bd5760006003193601126103bd576020604051308152f35b6001600160a01b037f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054163303612f5057565b60246040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152fd5b6001600160a01b03809116908115613005577f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300805490837fffffffffffffffffffffffff00000000000000000000000000000000000000008316179055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b60246040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152fd5b908160209103126103bd575190565b6040513d6000823e3d90fd5b90600182811c9216801561309a575b602083101461306b57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f1691613060565b90600092918054916130b583613051565b91828252600193848116908160001461311757506001146130d7575b50505050565b90919394506000526020928360002092846000945b8386106131035750505050010190388080806130d1565b8054858701830152940193859082016130ec565b91505060209495507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff009193501683830152151560051b010190388080806130d1565b91906001600160a01b038084161561214e57811615611120576113489261317e615dcd565b61586a565b91906131c58161093a856001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b5460001981036131d55750505050565b82811061323f576001600160a01b03808516156109bb5782161561098a576132359261093a9103936001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b55388080806130d1565b6040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526001600160a01b0392909216600483015260248201526044810191909152606490fd5b90813b1561334e576001600160a01b0382167f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc817fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a280511561331b57613318916133b8565b50565b50503461332457565b60046040517fb398979f000000000000000000000000000000000000000000000000000000008152fd5b6024826001600160a01b03604051917f4c9c8ce3000000000000000000000000000000000000000000000000000000008352166004820152fd5b3d156133b3573d906133998261134a565b916133a76040519384611318565b82523d6000602084013e565b606090565b6000806106d093602081519101845af46133d0613388565b915b9061341157508051156133e757805190602001fd5b60046040517f1425ea42000000000000000000000000000000000000000000000000000000008152fd5b8151158061345c575b613422575090565b6024906001600160a01b03604051917f9996b315000000000000000000000000000000000000000000000000000000008352166004820152fd5b50803b1561341a565b9061134861347992604051938480926130a4565b0383611318565b1561348757565b608460405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152fd5b81601f820112156103bd5780516135078161134a565b926135156040519485611318565b818452602082840101116103bd576106d09160208085019101610677565b906020828203126103bd57815167ffffffffffffffff81116103bd576106d092016134f1565b601f8260209493601f19938186528686013760008582860101520116010190565b60409061ffff6106d095931681528160208201520191613559565b8181106135a0575050565b60008155600101613595565b90601f82116135b9575050565b611348917f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace036000527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0906020601f840160051c83019310613622575b601f0160051c0190613595565b9091508190613615565b90601f8211613639575050565b611348917f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace046000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa906020601f840160051c8301931061362257601f0160051c0190613595565b9190601f81116136b057505050565b611348926000526020600020906020601f840160051c8301931061362257601f0160051c0190613595565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec820191821161373757565b6136db565b90601f820180921161373757565b9190820180921161373757565b1561375e57565b606460405162461bcd60e51b815260206004820152600e60248201527f736c6963655f6f766572666c6f770000000000000000000000000000000000006044820152fd5b156137a957565b606460405162461bcd60e51b815260206004820152601160248201527f736c6963655f6f75744f66426f756e64730000000000000000000000000000006044820152fd5b613801826137fa8161373c565b1015613757565b61380e82825110156137a2565b81613826575050604051600081526020810160405290565b60405191601f811691821560051b808486010193838501920101905b80841061385a5750508252601f01601f191660405290565b9092835181526020809101930190613842565b9290915a9260405160208101947f66ad5c8a00000000000000000000000000000000000000000000000000000000865261ffff8716602483015260806044830152613910826139026138c260a483018761069a565b67ffffffffffffffff881660648401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8382030160848401528861069a565b03601f198101845283611318565b6000809160405197613921896112fc565b609689528260208a019560a036883751923090f1903d9060968211613968575b6000908288523e15613955575b5050505050565b61395e94613971565b388080808061394e565b60969150613941565b9193613a507fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c95613a5e939561ffff81516020830120961695866000527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600602052613a16836139f460208b60406000208260405194838680955193849201610677565b8201908152030190209067ffffffffffffffff16600052602052604060002090565b5567ffffffffffffffff613a3c604051988998895260a060208a015260a089019061069a565b92166040870152858203606087015261069a565b90838203608085015261069a565b0390a1565b15613a6a57565b608460405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f6160448201527f64000000000000000000000000000000000000000000000000000000000000006064820152fd5b91613b019060609461ffff67ffffffffffffffff9499989799168552608060208601526080850191613559565b951660408201520152565b91908260409103126103bd576020825192015190565b91926001600160a01b036106d09795969461ffff613b549416855216602084015260a0604084015260a083019061069a565b93151560608201526080818503910152613559565b91602081019161ffff918284511615600014611b455780518101918183039460e086126103bd57613b9a90516103b1565b604082015193613ba9856108b1565b606083015193613bb8856108b1565b608084015167ffffffffffffffff81116103bd57613c017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809160208060609501918801016134f1565b9701126103bd57611b1a7fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf95611af9611b0398611af3613c489660405198611aa88a61128c565b0390a3565b929190613c6460209160408652604086019061069a565b930152565b92613ca19060409260c094979697600087526001600160a01b038092166020880152168386015260e0606086015260e085019061069a565b9480516080850152602081015160a08501520151910152565b92613cdf6106d097959361ffff613ced9416865260c0602087015260c086019061069a565b90848203604086015261069a565b936001600160a01b03809216606084015216608082015260a081840391015261069a565b94613d599193929561ffff81166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00602052613d606040600020604051948580926130a4565b0384611318565b825115613dff57613d72855182613e69565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001693843b156103bd57600096613de191604051998a98899788967fc580310000000000000000000000000000000000000000000000000000000000885260048801613cba565b03925af180156108a857613df25750565b8061290e61134892611273565b608460405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201527f61207472757374656420736f75726365000000000000000000000000000000006064820152fd5b613ea09061ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604060002090565b54908115613ef4575b11613eb057565b606460405162461bcd60e51b815260206004820152602060248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c617267656044820152fd5b6127109150613ea9565b9060ff7f822492242235517548c4a8cf040400e3c0daf5b82af652ed16dce4fa3ae72800541660001461401c576022815110613fd857613f736022613f829201519261ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602052604060002090565b60008052602052604060002090565b548015613f945761134891101561408f565b606460405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f74207365740000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d73000000006044820152fd5b90505161402557565b608460405162461bcd60e51b815260206004820152602660248201527f4f4654436f72653a205f61646170746572506172616d73206d7573742062652060448201527f656d7074792e00000000000000000000000000000000000000000000000000006064820152fd5b1561409657565b606460405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f7700000000006044820152fd5b81156140e4570490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b670de0b6b3a764000080820290600019818409908280831092039180830392146141a0578181111561417657807faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac10669940990828211900360ee1b910360121c170290565b60046040517f227bc153000000000000000000000000000000000000000000000000000000008152fd5b9250500490565b90808202906000198184099082808310920391808303921461420b57670de0b6b3a76400009082821115614176577faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac10669940990828211900360ee1b910360121c170290565b5050670de0b6b3a764000091500490565b670de0b6b3a764000091828202916000198482099383808610950394808603951461429a57848311156141765782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b5050906106d092506140da565b9190916142b48184614721565b92336001600160a01b0383160361430b575b7f0000000000000000000000000000000000000000000000000000000000000000156142ff57611348916142f8615dcd565b309061586a565b61134891612107615dcd565b614316813384613183565b6142c6565b601481511061432e576020015160601c90565b606460405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152fd5b7fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b5005490818310156143a257505050565b7f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00908154918183036143ff575b50505081036143db5750565b7fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b50055565b8190557f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b01549061442f8183614855565b61445b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025493836141a7565b918383018093116137375781614470916141a7565b928301809311613737577f6ca2c7f8c5de3c237b7dd3299cdfa19a8f0134a01ebccfc347d6d5c0ed80518b9260809260405192338452602084015260408301526060820152a13880806143cf565b93909291926040519361ffff60208601967f33b4b4240000000000000000000000000000000000000000000000000000000088521660248601526001600160a01b03809216604486015216606484015230608484015260a483015260a4825260e082019282841067ffffffffffffffff851117611287576000809493819460405251925af190565b90614573907f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054906141a7565b90817f0000000000000000000000000000000000000000000000000000000000000000156145ad576106d0916145a7615dcd565b3061586a565b6106d0916110ac615dcd565b60ff6145f7826001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b54161561463e5761463a906001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b5490565b61467d6106d0916001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b547f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054906141a7565b6146f37f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b01547f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054906141a7565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025481018091116137375790565b919061475f816001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b54927f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00549161478e83866141a7565b908183116147ac575081106147a1575050565b6106d092935061421c565b6040517fa47b7c650000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481019190915260448101829052606490fd5b61480090614113565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025481011061482b57565b60046040517fc31f6f5e000000000000000000000000000000000000000000000000000000008152fd5b90614800916141a7565b60405161486b816112e0565b600981526020907f555320542d42696c6c000000000000000000000000000000000000000000000082820152604051916148a4836112e0565b600483527f5553544200000000000000000000000000000000000000000000000000000000818401526148d5614ac4565b6148dd614ac4565b6148e5614ac4565b6148ed614ac4565b6148f5614ac4565b6148fd614ac4565b614905614ac4565b61490d614ac4565b614915614ac4565b61491d614ac4565b614925614ac4565b61492d614ac4565b614935614ac4565b61493e33612f80565b614946614ac4565b61494e614ac4565b81519067ffffffffffffffff8211611287577f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0392614995836149908654613051565b6135ac565b81601f8411600114614a15575091806149cf9492611348979694600092614a0a575b50506000198260011b9260031b1c1916179055614b1d565b7f000000000000000000000000000000000000000000000000000000000000000015614a02576149fd615dcd565b615ec3565b6149fd615beb565b0151905038806149b7565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace036000529190601f1984167f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0936000905b828210614aac5750509260019285926113489998966149cf989610614a93575b505050811b019055614b1d565b015160001960f88460031b161c19169055388080614a86565b80600186978294978701518155019601940190614a66565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615614af357565b60046040517fd7e6bcf8000000000000000000000000000000000000000000000000000000008152fd5b90815167ffffffffffffffff8111611287577f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0490614b6481614b5f8454613051565b61362c565b602080601f8311600114614b9f575081929394600092614b94575b50506000198260011b9260031b1c1916179055565b015190503880614b7f565b90601f19831695614bf17f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace046000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa90565b926000905b888210614c2e57505083600195969710614c15575b505050811b019055565b015160001960f88460031b161c19169055388080614c0b565b80600185968294968601518155019501930190614bf6565b6000806001600160a01b03614c7093169360208151910182865af1614c69613388565b90836133d2565b8051908115159182614cb7575b5050614c865750565b602490604051907f5274afe70000000000000000000000000000000000000000000000000000000082526004820152fd5b81925090602091810103126103bd5760200151614cd381610cff565b153880614c7d565b15614ce257565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b614d50611e0b826001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b82151590151503614d5f575050565b6001600160a01b0391614d71826145b9565b80151580614e6a575b614dea83614dba866001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b9060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b614e45575b5015614e1d57167f7352fb0f5f18099924dda972622029eeba5e48373776e3ea7a5a8906788e6021600080a2565b167ff543346dff2dc16795cb14790d14394516366a2ee1b3c7715ba7f01075ba6660600080a2565b8115614e5b57614e55908361501d565b38614def565b614e65908361530d565b614e55565b8215614e7f57614e7a82856155dd565b614d7a565b614e7a82855b6001600160a01b0381169081614f1e57507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace02805490838201809211613737576000937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092555b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace02818154039055604051908152a3565b9291614f5c846001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b5493818510614fd25781602091614fcc7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946000979803916001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b55614eee565b6040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481018590526044810191909152606490fd5b907f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0280548281018091116137375781556001600160a01b038316926000927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef926020928661509657508181540390555b604051908152a3565b6150d391506001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b81815401905561508d565b90916001600160a01b038083169283615215575081613c489161516a6151467fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef957f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025461374a565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0255565b851694856151ce57506151be817f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0254037f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0255565b6040519081529081906020820190565b61520a906001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b8181540190556151be565b615251816001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b548381106152c5579183916152bf7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef95613c489503916001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b5561516a565b6040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152602482015260448101839052606490fd5b60008080527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052916153607fe6b222ef0621f602fe2ae4f5a2ae56d98478a1e30369ecfec219e0c1cd48eb19611e0b565b906153a0611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b9282806155d6575b6155c8577f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054936153d9858461421c565b938115615567576153e984615baf565b6001600160a01b03938385166154b657508015615466575b615461575b908291615459575b1693169183830361541f5750505050565b6151be61544d917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef936141a7565b0390a3388080806130d1565b50600061540e565b615406565b6154b1857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b615401565b82156154c6576154b1908461501d565b50615503836001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b8581540190558080615560575b15615401576154b1857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154017f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b5086615510565b6155c3615595867f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015461374a565b61559f8882614855565b7f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b6153e9565b91509150611348925061501d565b50836153a8565b90600090615620611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b600080527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052906156727fe6b222ef0621f602fe2ae4f5a2ae56d98478a1e30369ecfec219e0c1cd48eb19611e0b565b928280615863575b615856577f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054936156ab858461421c565b936001600160a01b03938780861661578457508215615750576156cd90615baf565b8015615700575b6156f6575b9082916156f1571693169183830361541f5750505050565b61540e565b90945084906156d9565b61574b857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b6156d4565b5061577f615595867f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015461374a565b6156cd565b9082156157a057505061577f61579a87876141a7565b88614e85565b6157ab929650614721565b93818061584f575b6157ff575b6157f4876001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b8581540390556156cd565b61584a857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b6157b8565b50826157b3565b5091505061134891614e85565b508361567a565b916158aa611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b906158ea611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b928280615ba8575b615b9b577f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b005493615923858461421c565b93806001600160a01b03948589161580600014615ac0578415615a835761594982615baf565b8587166159cd5750501561597d575b61597457908291615459571693169183830361541f5750505050565b60009550615406565b6159c8857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b615958565b84156159df57506159c891508461501d565b9050615a1d856001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b87815401905581615a7a575b5015615958576159c8857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154017f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b90501538615a29565b615abb615ab1897f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015461374a565b61559f8b82614855565b615949565b9115615ade57508190615ad388886141a7565b90615abb828b614e85565b82919650615aec8982614721565b968480615b90575b615b40575b615b358a6001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b888154039055615949565b615b8b887f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b615af9565b508686161515615af4565b91509150611348926150de565b50836158f2565b615bb76146a6565b80910110615bc157565b60046040517f7ebdee1b000000000000000000000000000000000000000000000000000000008152fd5b6001600160a01b037f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00541633141580615d9e575b610c02577f0000000000000000000000000000000000000000000000000000000000000000610c61577fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b500548060011015615c765750565b7f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00805490670de0b6b3a764000090818303615ce1575b505050600103615cb857565b61134860017fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b50055565b8190557f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015490615d10826147f7565b615d3c7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025493836141a7565b9183830180931161373757615d5090614113565b928301809311613737577f6ca2c7f8c5de3c237b7dd3299cdfa19a8f0134a01ebccfc347d6d5c0ed80518b9260809260405192338452602084015260408301526060820152a1388080615cac565b5060ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615615c1f565b7f0000000000000000000000000000000000000000000000000000000000000000615df457565b6040517f6f2c590a0000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa9081156108a857600091615e92575b507f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00548103615e875750565b611348904390614372565b906020823d8211615ebb575b81615eab60209383611318565b810103126107f757505138615e5b565b3d9150615e9e565b6001600160a01b0390615ed4612f1d565b168015610bd85760207f2f2bf8dfa9db3b9a1760050db61b562dd190c82161ca91a2456aceb26ac2df45917f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00817fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055604051908152a156fea164736f6c6343000814000a00000000000000000000000059d9356e565ab3a36dd77763fc0d87feaf85508c000000000000000000000000000000000000000000000000000000000000000100000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c80621d3567146103ac57806301ffc9a7146103a757806306fdde03146103a257806307e0db171461039d578063095ea7b3146103985780630df374831461039357806310ddb1371461038e57806311a4e7861461038957806318160ddd1461031157806323b872dd146103845780632a205e3d1461037f578063313ce5671461037a5780633d8b38f6146103755780633d96cedf146103705780633f1f4fa41461036b57806340c10f191461036657806342d65a8d14610361578063447705151461035757806347e1b3721461035c5780634c42899a146103575780634f1ef28614610352578063519056361461034d57806351c977601461034857806352d1902d146103435780635b8c41e61461033e57806366ad5c8a146103395780636cae7d0f1461033457806370a082311461032f578063715018a61461032a5780637533d7881461032557806380d1dfa8146103205780638cfd8f5c1461031b5780638da5cb5b146103165780639358928b14610311578063950c8a741461030c57806395d89b41146103075780639dc29fac146103025780639f38369a146102fd578063a6c3d165146102f8578063a9059cbb146102f3578063aa888223146102ee578063ad3cb1cc146102e9578063b353aaa7146102e4578063b834f6fb146102df578063baf3292d146102da578063c4461834146102d5578063c4d66de8146102d0578063c5d664c6146102cb578063cbed8b9c146102c6578063d1deba1f146102c1578063dd62ed3e146102bc578063df2a5b3b146102b7578063eab45d9c146102b2578063eb8d72b7146102ad578063f2fde38b146102a8578063f5ecbdbc146102a3578063f672ade41461029e5763fc0c546a1461029957600080fd5b612f02565b612ebc565b612dcf565b612da2565b612c37565b612b98565b612ae8565b612a7e565b612914565b61280e565b6127ca565b6125d3565b6125b6565b612513565b6124d6565b612492565b612434565b61241b565b6123f1565b612250565b61218f565b612095565b611fcd565b611f87565b610c91565b611f41565b611ec9565b611d8c565b611d16565b611c82565b611c5b565b611bf3565b6119a1565b6118d8565b611843565b611798565b61159c565b61139d565b6111eb565b611207565b611151565b611042565b610fe4565b610f3a565b610ebf565b610e6a565b610d09565b610cb4565b610af0565b610a4e565b6109ec565b6108c2565b6107fa565b6106d3565b610588565b610456565b61ffff8116036103bd57565b600080fd5b9181601f840112156103bd5782359167ffffffffffffffff83116103bd57602083818601950101116103bd57565b9060806003198301126103bd57600435610409816103b1565b9167ffffffffffffffff906024358281116103bd578161042b916004016103c2565b9390939260443581811681036103bd57926064359182116103bd57610452916004016103c2565b9091565b346103bd57610464366103f0565b91929493906001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6751633036105445761050761050f92610515976105006104e66104e18a61ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00602052604060002090565b613465565b805190818414918261053a575b5081610517575b50613480565b3691611366565b923691611366565b9261386d565b005b9050610524368486611366565b60208151910120906020815191012014386104fa565b15159150386104f3565b606460405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c657200006044820152fd5b346103bd5760206003193601126103bd576004357fffffffff0000000000000000000000000000000000000000000000000000000081168091036103bd578060209115908115610642575b81156105e5575b506040519015158152f35b7f14e4ceea00000000000000000000000000000000000000000000000000000000811491508115610618575b50386105da565b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501438610611565b7f36372b0700000000000000000000000000000000000000000000000000000000811491506105d3565b60009103126103bd57565b60005b83811061068a5750506000910152565b818101518382015260200161067a565b90601f19601f6020936106b881518092818752878088019101610677565b0116010190565b9060206106d092818152019061069a565b90565b346103bd576000806003193601126107f75760405190807f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace039081549061071882613051565b808652926001928084169081156107ac5750600114610752575b61074e8661074281880382611318565b604051918291826106bf565b0390f35b815292507f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab05b8284106107945750505081016020016107428261074e38610732565b80546020858701810191909152909301928101610778565b87965061074e979450602093506107429592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b820101929338610732565b80fd5b346103bd57600060206003193601126107f757600435610819816103b1565b610821612f1d565b816001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6751691823b156108ad57602461ffff918360405195869485937f07e0db170000000000000000000000000000000000000000000000000000000085521660048401525af180156108a85761089c575080f35b6108a590611273565b80f35b613045565b5080fd5b6001600160a01b038116036103bd57565b346103bd5760406003193601126103bd576004356108df816108b1565b60243533156109bb576001600160a01b03821691821561098a57610952829161093a336001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b906001600160a01b0316600052602052604060002090565b556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b60246040517f94280d6200000000000000000000000000000000000000000000000000000000815260006004820152fd5b60246040517fe602df0500000000000000000000000000000000000000000000000000000000815260006004820152fd5b346103bd5760406003193601126103bd57600435610a09816103b1565b610a11612f1d565b610a4b6024359161ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604060002090565b55005b346103bd57600060206003193601126107f757600435610a6d816103b1565b610a75612f1d565b816001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6751691823b156108ad57602461ffff918360405195869485937f10ddb1370000000000000000000000000000000000000000000000000000000085521660048401525af180156108a85761089c575080f35b346103bd5760606003193601126103bd57600435604435610b10816108b1565b60017f0000000000000000000000000000000000000000000000000000000000000001151503610c61576001600160a01b03807f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00541633141580610c32575b610c0257811615610bd85761051591610b86615dcd565b610bb47f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b005460243514614cdb565b610bbd306145b9565b610bc8828211614cdb565b610bd0615dcd565b03903061586a565b60046040517ff6b2911f000000000000000000000000000000000000000000000000000000008152fd5b60246040517f4a0bfec1000000000000000000000000000000000000000000000000000000008152336004820152fd5b5060ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615610b6f565b60246040517fc3a55c98000000000000000000000000000000000000000000000000000000008152466004820152fd5b346103bd5760006003193601126103bd576020610cac6146a6565b604051908152f35b346103bd5760606003193601126103bd57610cf4600435610cd4816108b1565b602435610ce0816108b1565b60443591610cef833383613183565b613159565b602060405160018152f35b801515036103bd57565b346103bd5760a06003193601126103bd57600435610d26816103b1565b67ffffffffffffffff906024358281116103bd57610d489036906004016103c2565b9060643592610d5684610cff565b6084359485116103bd57610de4610d74610daf9636906004016103c2565b906040978896610d9988519788926000602085015260608b8501526080840191613559565b604435606083015203601f198101875286611318565b855196879586957f40a7bb10000000000000000000000000000000000000000000000000000000008752309060048801613b22565b03816001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675165afa9182156108a8576000918293610e35575b50519081526020810191909152604090f35b81610e5b92945061074e93503d8511610e63575b610e538183611318565b810190613b0c565b929091610e23565b503d610e49565b346103bd5760006003193601126103bd57602060405160128152f35b9060406003198301126103bd57600435610e9f816103b1565b916024359067ffffffffffffffff82116103bd57610452916004016103c2565b346103bd57602061ffff610f2b610ed536610e86565b939091166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b008452610f16610f1d6040600020604051928380926130a4565b0382611318565b848151910120923691611366565b82815191012014604051908152f35b346103bd5760206003193601126103bd576001600160a01b03600435610f5f816108b1565b610f67612f1d565b168015610bd85760207f2f2bf8dfa9db3b9a1760050db61b562dd190c82161ca91a2456aceb26ac2df45917f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00817fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055604051908152a1005b346103bd5760206003193601126103bd576020611039600435611006816103b1565b61ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604060002090565b54604051908152f35b346103bd5760406003193601126103bd5760043561105f816108b1565b60243560017f0000000000000000000000000000000000000000000000000000000000000001151503610c61576001600160a01b0380831615611120576110b182610515946110ac615dcd565b61530d565b604051917f23b872dd0000000000000000000000000000000000000000000000000000000060208401523360248401523060448401526064830152606482526110f9826112a8565b7f00000000000000000000000059d9356e565ab3a36dd77763fc0d87feaf85508c16614c46565b60246040517fec442f0500000000000000000000000000000000000000000000000000000000815260006004820152fd5b346103bd5761115f36610e86565b9190611169612f1d565b6001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6751691823b156103bd57604051928380927f42d65a8d000000000000000000000000000000000000000000000000000000008252816111d9600098899788946004850161357a565b03925af180156108a85761089c575080f35b346103bd5760006003193601126103bd57602060405160008152f35b346103bd5760006003193601126103bd5760207f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054604051908152f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff811161128757604052565b611244565b6060810190811067ffffffffffffffff82111761128757604052565b60a0810190811067ffffffffffffffff82111761128757604052565b6080810190811067ffffffffffffffff82111761128757604052565b6040810190811067ffffffffffffffff82111761128757604052565b60c0810190811067ffffffffffffffff82111761128757604052565b90601f601f19910116810190811067ffffffffffffffff82111761128757604052565b604051906113488261128c565b565b67ffffffffffffffff811161128757601f01601f191660200190565b9291926113728261134a565b916113806040519384611318565b8294818452818301116103bd578281602093846000960137010152565b60406003193601126103bd5760048035906113b7826108b1565b60243567ffffffffffffffff81116103bd57366023820112156103bd576113e79036906024818501359101611366565b6001600160a01b03807f0000000000000000000000003889d08ea90a811dce087cedec893e5697c92c6b1680301490811561156e575b5061154557906020839261142f612f1d565b604051938480927f52d1902d00000000000000000000000000000000000000000000000000000000825288165afa60009281611515575b506114ad5750506040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0390921690820190815281906020010390fd5b83837f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc84036114e0576105158383613288565b6040517faa1d49a400000000000000000000000000000000000000000000000000000000815290810184815281906020010390fd5b61153791935060203d811161153e575b61152f8183611318565b810190613036565b9138611466565b503d611525565b826040517fe07c8dba000000000000000000000000000000000000000000000000000000008152fd5b9050817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc541614153861141d565b60e06003193601126103bd576004356115b4816108b1565b6024356115c0816103b1565b67ffffffffffffffff6044358181116103bd576115e19036906004016103c2565b9091608435906115f0826108b1565b60a435926115fd846108b1565b60c4359182116103bd5761162561161b61162d9336906004016103c2565b9690923691611366565b943691611366565b9260ff61166c876001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b541661175e57611757610515966116838688613efe565b611749611692606435836142a7565b886116f77f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00547fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b50054936116e361133b565b9481865282602087015260408601526141a7565b7f39a4c66499bcf4b56d79f0dde8ed7a9d4925a0df55825206b2b8531e202be0d06040518061173661ffff6001600160a01b038a169616948b83613c4d565b0390a36040519485933360208601613c69565b03601f198101835282611318565b3494613d11565b6040517f63b4968b0000000000000000000000000000000000000000000000000000000081526001600160a01b0387166004820152602490fd5b346103bd5760406003193601126103bd576001600160a01b037f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00541633141580611814575b610c02577f0000000000000000000000000000000000000000000000000000000000000001610c6157610515602435600435614372565b5060ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c16156117dd565b346103bd5760006003193601126103bd576001600160a01b037f0000000000000000000000003889d08ea90a811dce087cedec893e5697c92c6b1630036118ae5760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b60046040517fe07c8dba000000000000000000000000000000000000000000000000000000008152fd5b346103bd5760606003193601126103bd576004356118f5816103b1565b67ffffffffffffffff6024358181116103bd576119169036906004016103c2565b60449291923591821682036103bd5760206119909361196561074e9661ffff166000527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600602052604060002090565b8360405194859384378201908152030190209067ffffffffffffffff16600052602052604060002090565b546040519081529081906020820190565b346103bd576119af366103f0565b9392909150303303611b89576119ca92610507913691611366565b602081019161ffff918284511615600014611b455780518101918183039460e086126103bd576119fa90516103b1565b604082015193611a09856108b1565b606083015193611a18856108b1565b608084015167ffffffffffffffff81116103bd57611a617fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809160208060609501918801016134f1565b9701126103bd57611b1a7fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf95611af9611b0398611af3611b309660405198611aa88a61128c565b60a08101518a5260e060c0820151918260208d015201518060408c01527f000000000000000000000000000000000000000000000000000000000000000115611b35575b505061431b565b5061431b565b9788955186614546565b9788916001600160a01b038080991691168b6144be565b5060405193849316961694829190602083019252565b0390a3005b611b3e91614372565b3880611aec565b606460405162461bcd60e51b815260206004820152601c60248201527f4f4654436f72653a20756e6b6e6f776e207061636b65742074797065000000006044820152fd5b608460405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d75737420626560448201527f204c7a41707000000000000000000000000000000000000000000000000000006064820152fd5b346103bd5760206003193601126103bd57602060ff611c4f600435611c17816108b1565b6001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b54166040519015158152f35b346103bd5760206003193601126103bd576020610cac600435611c7d816108b1565b6145b9565b346103bd576000806003193601126107f757611c9c612f1d565b806001600160a01b037f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993008054907fffffffffffffffffffffffff000000000000000000000000000000000000000082169055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346103bd5760206003193601126103bd5761ffff600435611d36816103b1565b166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b0060205261074e610f16611d786040600020604051928380926130a4565b60405191829160208352602083019061069a565b346103bd5760406003193601126103bd57600435611da9816108b1565b602435611db581610cff565b6001600160a01b03821633141580611e80575b611e4f57611e12611e0b836001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b5460ff1690565b151581151514611e255761051591614d11565b60046040517fdf82d43b000000000000000000000000000000000000000000000000000000008152fd5b6040517f4a0bfec1000000000000000000000000000000000000000000000000000000008152336004820152602490fd5b50611ec1611eb57f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00546001600160a01b031690565b6001600160a01b031690565b331415611dc8565b346103bd5760406003193601126103bd576020611039600435611eeb816103b1565b611f2e60243591611efb836103b1565b61ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602052604060002090565b9061ffff16600052602052604060002090565b346103bd5760006003193601126103bd5760206001600160a01b037f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b346103bd5760006003193601126103bd5760206001600160a01b037f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b035416604051908152f35b346103bd576000806003193601126107f75760405190807f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace049081549061201282613051565b808652926001928084169081156107ac575060011461203b5761074e8661074281880382611318565b815292507f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa5b82841061207d5750505081016020016107428261074e38610732565b80546020858701810191909152909301928101612061565b346103bd5760406003193601126103bd576004356120b2816108b1565b60243560017f0000000000000000000000000000000000000000000000000000000000000001151503610c61576001600160a01b0380831633810361217f575b1561214e5761210c8261051594612107615dcd565b6155dd565b604051917fa9059cbb0000000000000000000000000000000000000000000000000000000060208401523360248401526044830152604482526110f9826112c4565b60246040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260006004820152fd5b61218a833386613183565b6120f2565b346103bd5760206003193601126103bd5761ffff6004356121af816103b1565b166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00602052610f166121ee6040600020604051928380926130a4565b80511561220c576107428161220661074e935161370a565b906137ed565b606460405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f72640000006044820152fd5b346103bd5761225e36610e86565b9190612268612f1d565b6040519160208483828601376122936034858781013060601b85820152036014810187520185611318565b60009361ffff831685527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b008252604085209181519167ffffffffffffffff8311611287576122eb836122e58654613051565b866136a1565b81601f841160011461235b5750918061234a94928899947f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce9992612350575b50506000198260011b9260031b1c19161790555b6040519384938461357a565b0390a180f35b01519050388061232a565b9190601f19841661237186600052602060002090565b9389905b8282106123d95750509260019285927f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce9a9b9661234a9896106123c0575b505050811b01905561233e565b015160001960f88460031b161c191690553880806123b3565b80600186978294978701518155019601940190612375565b346103bd5760406003193601126103bd57610cf4600435612411816108b1565b6024359033613159565b346103bd5760006003193601126103bd57610515615dcd565b346103bd5760006003193601126103bd5761074e604051612454816112e0565b600581527f352e302e30000000000000000000000000000000000000000000000000000000602082015260405191829160208352602083019061069a565b346103bd5760006003193601126103bd5760206040516001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675168152f35b346103bd5760006003193601126103bd5760206040517f000000000000000000000000000000000000000000000000000000000000000115158152f35b346103bd5760206003193601126103bd577f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b60206001600160a01b0360043561255b816108b1565b612563612f1d565b167f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b03817fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055604051908152a1005b346103bd5760006003193601126103bd5760206040516127108152f35b346103bd5760206003193601126103bd576004356125f0816108b1565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549067ffffffffffffffff60ff8360401c16159216801590816127c2575b60011490816127b8575b1590816127af575b50612785576126a3908261269a7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0060017fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000825416179055565b6127295761485f565b6126a957005b6126f57ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff8154169055565b604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29080602081015b0390a1005b6127807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00680100000000000000007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff825416179055565b61485f565b60046040517ff92ee8a9000000000000000000000000000000000000000000000000000000008152fd5b90501538612641565b303b159150612639565b83915061262f565b346103bd5760006003193601126103bd5760206040516001600160a01b037f00000000000000000000000059d9356e565ab3a36dd77763fc0d87feaf85508c168152f35b346103bd5760806003193601126103bd5760043561282b816103b1565b602435612837816103b1565b60643567ffffffffffffffff81116103bd576128579036906004016103c2565b9092612861612f1d565b6001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6751690813b156103bd57600080946128f1604051978896879586947fcbed8b9c00000000000000000000000000000000000000000000000000000000865261ffff80921660048701521660248501526044356044850152608060648501526084840191613559565b03925af180156108a85761290157005b8061290e61051592611273565b8061066c565b61291d366103f0565b94929161ffff84166000527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d860060205260406000206020604051809286898337868201908152030190209261298582859067ffffffffffffffff16600052602052604060002090565b54928315612a14577fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e597612a01612a089260006129f5876127249a6129dc8b6129cf368a89611366565b6020815191012014613a63565b9067ffffffffffffffff16600052602052604060002090565b5561050736868c611366565b9087613b69565b60405195869586613ad4565b608460405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201527f61676500000000000000000000000000000000000000000000000000000000006064820152fd5b346103bd5760406003193601126103bd576020611039600435612aa0816108b1565b61093a60243591612ab0836108b1565b6001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b346103bd5760606003193601126103bd577f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac06060600435612b28816103b1565b60243590612b35826103b1565b60443590612b41612f1d565b81612b7d84611f2e8461ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602052604060002090565b556040519261ffff80921684521660208301526040820152a1005b346103bd5760206003193601126103bd577f1584ad594a70cbe1e6515592e1272a987d922b097ead875069cebe8b40c004a46020600435612bd881610cff565b612be0612f1d565b15157f822492242235517548c4a8cf040400e3c0daf5b82af652ed16dce4fa3ae728007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541660ff8316179055604051908152a1005b346103bd57612c4536610e86565b9190612c4f612f1d565b60009161ffff8116835260207f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b008152604084209067ffffffffffffffff861161128757612ca686612ca08454613051565b846136a1565b8490601f8711600114612d0e57509461234a918186977ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab9791612d03575b508260011b906000198460031b1c19161790556040519384938461357a565b905085013538612ce4565b90601f198716612d2384600052602060002090565b9287905b828210612d8a5750509161234a9391887ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab98999410612d70575b5050600182811b01905561233e565b60001960f88560031b161c19908701351690553880612d61565b80600185968294968b01358155019501930190612d27565b346103bd5760206003193601126103bd57610515600435612dc2816108b1565b612dca612f1d565b612f80565b346103bd5760806003193601126103bd57600435612dec816103b1565b60243590612df9826103b1565b612e046044356108b1565b604051917ff5ecbdbc00000000000000000000000000000000000000000000000000000000835261ffff809216600484015216602482015230604482015260643560648201526000816084816001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675165afa80156108a85761074e91600091612e9b575b50604051918291826106bf565b612eb6913d8091833e612eae8183611318565b810190613533565b38612e8e565b346103bd5760006003193601126103bd5760206001600160a01b037f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd005416604051908152f35b346103bd5760006003193601126103bd576020604051308152f35b6001600160a01b037f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054163303612f5057565b60246040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152fd5b6001600160a01b03809116908115613005577f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300805490837fffffffffffffffffffffffff00000000000000000000000000000000000000008316179055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b60246040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152fd5b908160209103126103bd575190565b6040513d6000823e3d90fd5b90600182811c9216801561309a575b602083101461306b57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f1691613060565b90600092918054916130b583613051565b91828252600193848116908160001461311757506001146130d7575b50505050565b90919394506000526020928360002092846000945b8386106131035750505050010190388080806130d1565b8054858701830152940193859082016130ec565b91505060209495507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff009193501683830152151560051b010190388080806130d1565b91906001600160a01b038084161561214e57811615611120576113489261317e615dcd565b61586a565b91906131c58161093a856001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b5460001981036131d55750505050565b82811061323f576001600160a01b03808516156109bb5782161561098a576132359261093a9103936001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace01602052604060002090565b55388080806130d1565b6040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526001600160a01b0392909216600483015260248201526044810191909152606490fd5b90813b1561334e576001600160a01b0382167f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc817fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a280511561331b57613318916133b8565b50565b50503461332457565b60046040517fb398979f000000000000000000000000000000000000000000000000000000008152fd5b6024826001600160a01b03604051917f4c9c8ce3000000000000000000000000000000000000000000000000000000008352166004820152fd5b3d156133b3573d906133998261134a565b916133a76040519384611318565b82523d6000602084013e565b606090565b6000806106d093602081519101845af46133d0613388565b915b9061341157508051156133e757805190602001fd5b60046040517f1425ea42000000000000000000000000000000000000000000000000000000008152fd5b8151158061345c575b613422575090565b6024906001600160a01b03604051917f9996b315000000000000000000000000000000000000000000000000000000008352166004820152fd5b50803b1561341a565b9061134861347992604051938480926130a4565b0383611318565b1561348757565b608460405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152fd5b81601f820112156103bd5780516135078161134a565b926135156040519485611318565b818452602082840101116103bd576106d09160208085019101610677565b906020828203126103bd57815167ffffffffffffffff81116103bd576106d092016134f1565b601f8260209493601f19938186528686013760008582860101520116010190565b60409061ffff6106d095931681528160208201520191613559565b8181106135a0575050565b60008155600101613595565b90601f82116135b9575050565b611348917f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace036000527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0906020601f840160051c83019310613622575b601f0160051c0190613595565b9091508190613615565b90601f8211613639575050565b611348917f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace046000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa906020601f840160051c8301931061362257601f0160051c0190613595565b9190601f81116136b057505050565b611348926000526020600020906020601f840160051c8301931061362257601f0160051c0190613595565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec820191821161373757565b6136db565b90601f820180921161373757565b9190820180921161373757565b1561375e57565b606460405162461bcd60e51b815260206004820152600e60248201527f736c6963655f6f766572666c6f770000000000000000000000000000000000006044820152fd5b156137a957565b606460405162461bcd60e51b815260206004820152601160248201527f736c6963655f6f75744f66426f756e64730000000000000000000000000000006044820152fd5b613801826137fa8161373c565b1015613757565b61380e82825110156137a2565b81613826575050604051600081526020810160405290565b60405191601f811691821560051b808486010193838501920101905b80841061385a5750508252601f01601f191660405290565b9092835181526020809101930190613842565b9290915a9260405160208101947f66ad5c8a00000000000000000000000000000000000000000000000000000000865261ffff8716602483015260806044830152613910826139026138c260a483018761069a565b67ffffffffffffffff881660648401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc8382030160848401528861069a565b03601f198101845283611318565b6000809160405197613921896112fc565b609689528260208a019560a036883751923090f1903d9060968211613968575b6000908288523e15613955575b5050505050565b61395e94613971565b388080808061394e565b60969150613941565b9193613a507fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c95613a5e939561ffff81516020830120961695866000527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600602052613a16836139f460208b60406000208260405194838680955193849201610677565b8201908152030190209067ffffffffffffffff16600052602052604060002090565b5567ffffffffffffffff613a3c604051988998895260a060208a015260a089019061069a565b92166040870152858203606087015261069a565b90838203608085015261069a565b0390a1565b15613a6a57565b608460405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f6160448201527f64000000000000000000000000000000000000000000000000000000000000006064820152fd5b91613b019060609461ffff67ffffffffffffffff9499989799168552608060208601526080850191613559565b951660408201520152565b91908260409103126103bd576020825192015190565b91926001600160a01b036106d09795969461ffff613b549416855216602084015260a0604084015260a083019061069a565b93151560608201526080818503910152613559565b91602081019161ffff918284511615600014611b455780518101918183039460e086126103bd57613b9a90516103b1565b604082015193613ba9856108b1565b606083015193613bb8856108b1565b608084015167ffffffffffffffff81116103bd57613c017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff809160208060609501918801016134f1565b9701126103bd57611b1a7fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf95611af9611b0398611af3613c489660405198611aa88a61128c565b0390a3565b929190613c6460209160408652604086019061069a565b930152565b92613ca19060409260c094979697600087526001600160a01b038092166020880152168386015260e0606086015260e085019061069a565b9480516080850152602081015160a08501520151910152565b92613cdf6106d097959361ffff613ced9416865260c0602087015260c086019061069a565b90848203604086015261069a565b936001600160a01b03809216606084015216608082015260a081840391015261069a565b94613d599193929561ffff81166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00602052613d606040600020604051948580926130a4565b0384611318565b825115613dff57613d72855182613e69565b6001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6751693843b156103bd57600096613de191604051998a98899788967fc580310000000000000000000000000000000000000000000000000000000000885260048801613cba565b03925af180156108a857613df25750565b8061290e61134892611273565b608460405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201527f61207472757374656420736f75726365000000000000000000000000000000006064820152fd5b613ea09061ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604060002090565b54908115613ef4575b11613eb057565b606460405162461bcd60e51b815260206004820152602060248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c617267656044820152fd5b6127109150613ea9565b9060ff7f822492242235517548c4a8cf040400e3c0daf5b82af652ed16dce4fa3ae72800541660001461401c576022815110613fd857613f736022613f829201519261ffff166000527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602052604060002090565b60008052602052604060002090565b548015613f945761134891101561408f565b606460405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f74207365740000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d73000000006044820152fd5b90505161402557565b608460405162461bcd60e51b815260206004820152602660248201527f4f4654436f72653a205f61646170746572506172616d73206d7573742062652060448201527f656d7074792e00000000000000000000000000000000000000000000000000006064820152fd5b1561409657565b606460405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f7700000000006044820152fd5b81156140e4570490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b670de0b6b3a764000080820290600019818409908280831092039180830392146141a0578181111561417657807faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac10669940990828211900360ee1b910360121c170290565b60046040517f227bc153000000000000000000000000000000000000000000000000000000008152fd5b9250500490565b90808202906000198184099082808310920391808303921461420b57670de0b6b3a76400009082821115614176577faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac10669940990828211900360ee1b910360121c170290565b5050670de0b6b3a764000091500490565b670de0b6b3a764000091828202916000198482099383808610950394808603951461429a57848311156141765782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b5050906106d092506140da565b9190916142b48184614721565b92336001600160a01b0383160361430b575b7f0000000000000000000000000000000000000000000000000000000000000001156142ff57611348916142f8615dcd565b309061586a565b61134891612107615dcd565b614316813384613183565b6142c6565b601481511061432e576020015160601c90565b606460405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152fd5b7fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b5005490818310156143a257505050565b7f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00908154918183036143ff575b50505081036143db5750565b7fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b50055565b8190557f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b01549061442f8183614855565b61445b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025493836141a7565b918383018093116137375781614470916141a7565b928301809311613737577f6ca2c7f8c5de3c237b7dd3299cdfa19a8f0134a01ebccfc347d6d5c0ed80518b9260809260405192338452602084015260408301526060820152a13880806143cf565b93909291926040519361ffff60208601967f33b4b4240000000000000000000000000000000000000000000000000000000088521660248601526001600160a01b03809216604486015216606484015230608484015260a483015260a4825260e082019282841067ffffffffffffffff851117611287576000809493819460405251925af190565b90614573907f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054906141a7565b90817f0000000000000000000000000000000000000000000000000000000000000001156145ad576106d0916145a7615dcd565b3061586a565b6106d0916110ac615dcd565b60ff6145f7826001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b54161561463e5761463a906001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b5490565b61467d6106d0916001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b547f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054906141a7565b6146f37f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b01547f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054906141a7565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025481018091116137375790565b919061475f816001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b54927f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00549161478e83866141a7565b908183116147ac575081106147a1575050565b6106d092935061421c565b6040517fa47b7c650000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481019190915260448101829052606490fd5b61480090614113565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025481011061482b57565b60046040517fc31f6f5e000000000000000000000000000000000000000000000000000000008152fd5b90614800916141a7565b60405161486b816112e0565b600981526020907f555320542d42696c6c000000000000000000000000000000000000000000000082820152604051916148a4836112e0565b600483527f5553544200000000000000000000000000000000000000000000000000000000818401526148d5614ac4565b6148dd614ac4565b6148e5614ac4565b6148ed614ac4565b6148f5614ac4565b6148fd614ac4565b614905614ac4565b61490d614ac4565b614915614ac4565b61491d614ac4565b614925614ac4565b61492d614ac4565b614935614ac4565b61493e33612f80565b614946614ac4565b61494e614ac4565b81519067ffffffffffffffff8211611287577f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0392614995836149908654613051565b6135ac565b81601f8411600114614a15575091806149cf9492611348979694600092614a0a575b50506000198260011b9260031b1c1916179055614b1d565b7f000000000000000000000000000000000000000000000000000000000000000115614a02576149fd615dcd565b615ec3565b6149fd615beb565b0151905038806149b7565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace036000529190601f1984167f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0936000905b828210614aac5750509260019285926113489998966149cf989610614a93575b505050811b019055614b1d565b015160001960f88460031b161c19169055388080614a86565b80600186978294978701518155019601940190614a66565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615614af357565b60046040517fd7e6bcf8000000000000000000000000000000000000000000000000000000008152fd5b90815167ffffffffffffffff8111611287577f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0490614b6481614b5f8454613051565b61362c565b602080601f8311600114614b9f575081929394600092614b94575b50506000198260011b9260031b1c1916179055565b015190503880614b7f565b90601f19831695614bf17f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace046000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa90565b926000905b888210614c2e57505083600195969710614c15575b505050811b019055565b015160001960f88460031b161c19169055388080614c0b565b80600185968294968601518155019501930190614bf6565b6000806001600160a01b03614c7093169360208151910182865af1614c69613388565b90836133d2565b8051908115159182614cb7575b5050614c865750565b602490604051907f5274afe70000000000000000000000000000000000000000000000000000000082526004820152fd5b81925090602091810103126103bd5760200151614cd381610cff565b153880614c7d565b15614ce257565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b614d50611e0b826001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b82151590151503614d5f575050565b6001600160a01b0391614d71826145b9565b80151580614e6a575b614dea83614dba866001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b9060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b614e45575b5015614e1d57167f7352fb0f5f18099924dda972622029eeba5e48373776e3ea7a5a8906788e6021600080a2565b167ff543346dff2dc16795cb14790d14394516366a2ee1b3c7715ba7f01075ba6660600080a2565b8115614e5b57614e55908361501d565b38614def565b614e65908361530d565b614e55565b8215614e7f57614e7a82856155dd565b614d7a565b614e7a82855b6001600160a01b0381169081614f1e57507f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace02805490838201809211613737576000937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092555b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace02818154039055604051908152a3565b9291614f5c846001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b5493818510614fd25781602091614fcc7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946000979803916001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b55614eee565b6040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481018590526044810191909152606490fd5b907f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0280548281018091116137375781556001600160a01b038316926000927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef926020928661509657508181540390555b604051908152a3565b6150d391506001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b81815401905561508d565b90916001600160a01b038083169283615215575081613c489161516a6151467fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef957f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025461374a565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0255565b851694856151ce57506151be817f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0254037f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace0255565b6040519081529081906020820190565b61520a906001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b8181540190556151be565b615251816001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b548381106152c5579183916152bf7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef95613c489503916001600160a01b03166000527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00602052604060002090565b5561516a565b6040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152602482015260448101839052606490fd5b60008080527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052916153607fe6b222ef0621f602fe2ae4f5a2ae56d98478a1e30369ecfec219e0c1cd48eb19611e0b565b906153a0611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b9282806155d6575b6155c8577f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054936153d9858461421c565b938115615567576153e984615baf565b6001600160a01b03938385166154b657508015615466575b615461575b908291615459575b1693169183830361541f5750505050565b6151be61544d917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef936141a7565b0390a3388080806130d1565b50600061540e565b615406565b6154b1857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b615401565b82156154c6576154b1908461501d565b50615503836001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b8581540190558080615560575b15615401576154b1857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154017f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b5086615510565b6155c3615595867f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015461374a565b61559f8882614855565b7f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b6153e9565b91509150611348925061501d565b50836153a8565b90600090615620611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b600080527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052906156727fe6b222ef0621f602fe2ae4f5a2ae56d98478a1e30369ecfec219e0c1cd48eb19611e0b565b928280615863575b615856577f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0054936156ab858461421c565b936001600160a01b03938780861661578457508215615750576156cd90615baf565b8015615700575b6156f6575b9082916156f1571693169183830361541f5750505050565b61540e565b90945084906156d9565b61574b857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b6156d4565b5061577f615595867f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015461374a565b6156cd565b9082156157a057505061577f61579a87876141a7565b88614e85565b6157ab929650614721565b93818061584f575b6157ff575b6157f4876001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b8581540390556156cd565b61584a857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b6157b8565b50826157b3565b5091505061134891614e85565b508361567a565b916158aa611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b906158ea611e0b846001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b03602052604060002090565b928280615ba8575b615b9b577f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b005493615923858461421c565b93806001600160a01b03948589161580600014615ac0578415615a835761594982615baf565b8587166159cd5750501561597d575b61597457908291615459571693169183830361541f5750505050565b60009550615406565b6159c8857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b615958565b84156159df57506159c891508461501d565b9050615a1d856001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b87815401905581615a7a575b5015615958576159c8857f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154017f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b90501538615a29565b615abb615ab1897f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015461374a565b61559f8b82614855565b615949565b9115615ade57508190615ad388886141a7565b90615abb828b614e85565b82919650615aec8982614721565b968480615b90575b615b40575b615b358a6001600160a01b03166000527f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b02602052604060002090565b888154039055615949565b615b8b887f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0154037f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b0155565b615af9565b508686161515615af4565b91509150611348926150de565b50836158f2565b615bb76146a6565b80910110615bc157565b60046040517f7ebdee1b000000000000000000000000000000000000000000000000000000008152fd5b6001600160a01b037f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00541633141580615d9e575b610c02577f0000000000000000000000000000000000000000000000000000000000000001610c61577fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b500548060011015615c765750565b7f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00805490670de0b6b3a764000090818303615ce1575b505050600103615cb857565b61134860017fdc2fee72b887a559c0d0f7379919bb4c097013a85e230aa333d867a22945b50055565b8190557f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b015490615d10826147f7565b615d3c7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025493836141a7565b9183830180931161373757615d5090614113565b928301809311613737577f6ca2c7f8c5de3c237b7dd3299cdfa19a8f0134a01ebccfc347d6d5c0ed80518b9260809260405192338452602084015260408301526060820152a1388080615cac565b5060ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615615c1f565b7f0000000000000000000000000000000000000000000000000000000000000001615df457565b6040517f6f2c590a0000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f00000000000000000000000059d9356e565ab3a36dd77763fc0d87feaf85508c165afa9081156108a857600091615e92575b507f8a0c9d8ec1d9f8b365393c36404b40a33f47675e34246a2e186fbefd5ecd3b00548103615e875750565b611348904390614372565b906020823d8211615ebb575b81615eab60209383611318565b810103126107f757505138615e5b565b3d9150615e9e565b6001600160a01b0390615ed4612f1d565b168015610bd85760207f2f2bf8dfa9db3b9a1760050db61b562dd190c82161ca91a2456aceb26ac2df45917f56cb630b12f1f031f72de1d734e98085323517cc6515c1c85452dc02f218dd00817fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055604051908152a156fea164736f6c6343000814000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000059d9356e565ab3a36dd77763fc0d87feaf85508c000000000000000000000000000000000000000000000000000000000000000100000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675
-----Decoded View---------------
Arg [0] : underlying (address): 0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C
Arg [1] : mainChainId (uint256): 1
Arg [2] : endpoint (address): 0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000059d9356e565ab3a36dd77763fc0d87feaf85508c
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [2] : 00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.