ERC-20
MEME
Overview
Max Total Supply
814,123,747.762002720494070674 MULLET
Holders
329 ( -0.304%)
Market
Price
$0.00 @ 0.000000 ETH (+0.48%)
Onchain Market Cap
$110,061.39
Circulating Supply Market Cap
$0.00
Other Info
Token Contract (WITH 18 Decimals)
Balance
110,890.183556201741102375 MULLETValue
$14.99 ( ~0.00636642133260411 Eth) [0.0136%]Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|---|---|---|---|---|
1 | ![]() | 0X7A569BFF9F87B526B39331CA870516C1D93C0FDA-0XC02AAA39B223FE8D0A0E5C4F27EAD9083C756CC2 | $0.0001 0.0000001 Eth | $183.42 1,376,312.552 0X7A569BFF9F87B526B39331CA870516C1D93C0FDA | 100.0000% |
Contract Source Code Verified (Exact Match)
Contract Name:
Mullet
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// Project Mullet ($MULLET) // Business in the front, party in the back // https://projectmullet.com // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol'; import '@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFT.sol'; import './interfaces/IBurnable.sol'; import './libraries/PoolAddress.sol'; import './GameTheoryRewards.sol'; import './LPAdapter.sol'; contract Mullet is IBurnable, OFT, ERC20Permit, LPAdapter { string constant NAME = 'Project Mullet'; string constant SYMBOL = 'MULLET'; string constant DESCRIPTION = 'Business in the front, party in the back'; uint256 constant LAUNCH_COOLDOWN = 3 minutes; uint256 constant FIRST_CLAIM_DELAY = 1 days; uint256 constant MINIMUM_LOCKUP_TIME = 3 days; uint256 constant LP_COLLECT_FREQUENCY = 60 minutes; uint256 constant LP_REBALANCE_FREQUENCY = 1 days; uint8 constant LP_REBALANCE_PERCENTAGE = 3; // % GameTheoryRewards public immutable GAME_THEORY_REWARDS; mapping(address => bool) _excludeRewards; constructor( address _weth, address _lpManager, address _v3Factory, address _swapRouter, address _layerZeroEndpoint, address _oftAdm ) OFT(NAME, SYMBOL, _layerZeroEndpoint, _oftAdm) ERC20Permit(NAME) LPAdapter( _oftAdm, _weth, _lpManager, _v3Factory, _swapRouter, LP_COLLECT_FREQUENCY, LP_REBALANCE_FREQUENCY, LP_REBALANCE_PERCENTAGE ) { GAME_THEORY_REWARDS = new GameTheoryRewards( FIRST_CLAIM_DELAY, MINIMUM_LOCKUP_TIME ); _excludeRewards[address(this)] = true; _excludeRewards[address(0)] = true; _excludeRewards[address(0xdead)] = true; _excludeRewards[_v3Pair(_v3Factory, address(this), _weth, 100)] = true; _excludeRewards[_v3Pair(_v3Factory, address(this), _weth, 500)] = true; _excludeRewards[_v3Pair(_v3Factory, address(this), _weth, 3000)] = true; _excludeRewards[_v3Pair(_v3Factory, address(this), _weth, 10000)] = true; _mint(_msgSender(), 1_000_000_000 * 10 ** 18); } function description() public pure returns (string memory) { return DESCRIPTION; } function burn(uint256 _amount) external override { _burn(_msgSender(), _amount); } function _update( address _from, address _to, uint256 _amount ) internal override { _checkAndProcessLPFees(); _checkAndRebalanceLp(); if (address(this).balance > 0) { GAME_THEORY_REWARDS.depositRewards{ value: address(this).balance }(); } uint256 _fee = _checkAndAddTempSniperFee(_from, _amount); if (_fee > 0) { super._update(_from, ADMIN, _fee); _afterTokenTransfer(_from, ADMIN, _fee); } super._update(_from, _to, _amount - _fee); _afterTokenTransfer(_from, _to, _amount - _fee); } function _checkAndAddTempSniperFee( address _from, uint256 _amount ) internal view returns (uint256 _fee) { if ( lpPositionId > 0 && _amount > 0 && _from == _liquidityPool && block.timestamp < _launchedAt + LAUNCH_COOLDOWN ) { _fee = _amount / 5; // 20% _fee = _fee == 0 ? _amount : _fee; } } function _v3Pair( address _factory, address _t0, address _t1, uint24 _poolFee ) internal pure returns (address) { (address _token0, address _token1) = (_t0 < _t1) ? (_t0, _t1) : (_t1, _t0); PoolAddress.PoolKey memory _key = PoolAddress.PoolKey({ token0: _token0, token1: _token1, fee: _poolFee }); return PoolAddress.computeAddress(_factory, _key); } function _afterTokenTransfer( address _from, address _to, uint256 _amount ) internal { if (!_excludeRewards[_from]) { require(GAME_THEORY_REWARDS.isUnlocked(_from), 'LK'); GAME_THEORY_REWARDS.update(_from, _amount, true); } if (!_excludeRewards[_to]) { GAME_THEORY_REWARDS.update(_to, _amount, false); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; /** * @title IOAppCore */ interface IOAppCore { // Custom error messages error OnlyPeer(uint32 eid, bytes32 sender); error NoPeer(uint32 eid); error InvalidEndpointCall(); error InvalidDelegate(); // Event emitted when a peer (OApp) is set for a corresponding endpoint event PeerSet(uint32 eid, bytes32 peer); /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. */ function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion); /** * @notice Retrieves the LayerZero endpoint associated with the OApp. * @return iEndpoint The LayerZero endpoint as an interface. */ function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint); /** * @notice Retrieves the peer (OApp) associated with a corresponding endpoint. * @param _eid The endpoint ID. * @return peer The peer address (OApp instance) associated with the corresponding endpoint. */ function peers(uint32 _eid) external view returns (bytes32 peer); /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. */ function setPeer(uint32 _eid, bytes32 _peer) external; /** * @notice Sets the delegate address for the OApp Core. * @param _delegate The address of the delegate to be set. */ function setDelegate(address _delegate) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @title IOAppMsgInspector * @dev Interface for the OApp Message Inspector, allowing examination of message and options contents. */ interface IOAppMsgInspector { // Custom error message for inspection failure error InspectionFailed(bytes message, bytes options); /** * @notice Allows the inspector to examine LayerZero message contents and optionally throw a revert if invalid. * @param _message The message payload to be inspected. * @param _options Additional options or parameters for inspection. * @return valid A boolean indicating whether the inspection passed (true) or failed (false). * * @dev Optionally done as a revert, OR use the boolean provided to handle the failure. */ function inspect(bytes calldata _message, bytes calldata _options) external view returns (bool valid); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @dev Struct representing enforced option parameters. */ struct EnforcedOptionParam { uint32 eid; // Endpoint ID uint16 msgType; // Message Type bytes options; // Additional options } /** * @title IOAppOptionsType3 * @dev Interface for the OApp with Type 3 Options, allowing the setting and combining of enforced options. */ interface IOAppOptionsType3 { // Custom error message for invalid options error InvalidOptions(bytes options); // Event emitted when enforced options are set event EnforcedOptionSet(EnforcedOptionParam[] _enforcedOptions); /** * @notice Sets enforced options for specific endpoint and message type combinations. * @param _enforcedOptions An array of EnforcedOptionParam structures specifying enforced options. */ function setEnforcedOptions(EnforcedOptionParam[] calldata _enforcedOptions) external; /** * @notice Combines options for a given endpoint and message type. * @param _eid The endpoint ID. * @param _msgType The OApp message type. * @param _extraOptions Additional options passed by the caller. * @return options The combination of caller specified options AND enforced options. */ function combineOptions( uint32 _eid, uint16 _msgType, bytes calldata _extraOptions ) external view returns (bytes memory options); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ILayerZeroReceiver, Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol"; interface IOAppReceiver is ILayerZeroReceiver { /** * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint. * @param _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @param _message The lzReceive payload. * @param _sender The sender address. * @return isSender Is a valid sender. * * @dev Applications can optionally choose to implement a separate composeMsg sender that is NOT the bridging layer. * @dev The default sender IS the OAppReceiver implementer. */ function isComposeMsgSender( Origin calldata _origin, bytes calldata _message, address _sender ) external view returns (bool isSender); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IOAppOptionsType3, EnforcedOptionParam } from "../interfaces/IOAppOptionsType3.sol"; /** * @title OAppOptionsType3 * @dev Abstract contract implementing the IOAppOptionsType3 interface with type 3 options. */ abstract contract OAppOptionsType3 is IOAppOptionsType3, Ownable { uint16 internal constant OPTION_TYPE_3 = 3; // @dev The "msgType" should be defined in the child contract. mapping(uint32 eid => mapping(uint16 msgType => bytes enforcedOption)) public enforcedOptions; /** * @dev Sets the enforced options for specific endpoint and message type combinations. * @param _enforcedOptions An array of EnforcedOptionParam structures specifying enforced options. * * @dev Only the owner/admin of the OApp can call this function. * @dev Provides a way for the OApp to enforce things like paying for PreCrime, AND/OR minimum dst lzReceive gas amounts etc. * @dev These enforced options can vary as the potential options/execution on the remote may differ as per the msgType. * eg. Amount of lzReceive() gas necessary to deliver a lzCompose() message adds overhead you dont want to pay * if you are only making a standard LayerZero message ie. lzReceive() WITHOUT sendCompose(). */ function setEnforcedOptions(EnforcedOptionParam[] calldata _enforcedOptions) public virtual onlyOwner { _setEnforcedOptions(_enforcedOptions); } /** * @dev Sets the enforced options for specific endpoint and message type combinations. * @param _enforcedOptions An array of EnforcedOptionParam structures specifying enforced options. * * @dev Provides a way for the OApp to enforce things like paying for PreCrime, AND/OR minimum dst lzReceive gas amounts etc. * @dev These enforced options can vary as the potential options/execution on the remote may differ as per the msgType. * eg. Amount of lzReceive() gas necessary to deliver a lzCompose() message adds overhead you dont want to pay * if you are only making a standard LayerZero message ie. lzReceive() WITHOUT sendCompose(). */ function _setEnforcedOptions(EnforcedOptionParam[] memory _enforcedOptions) internal virtual { for (uint256 i = 0; i < _enforcedOptions.length; i++) { // @dev Enforced options are only available for optionType 3, as type 1 and 2 dont support combining. _assertOptionsType3(_enforcedOptions[i].options); enforcedOptions[_enforcedOptions[i].eid][_enforcedOptions[i].msgType] = _enforcedOptions[i].options; } emit EnforcedOptionSet(_enforcedOptions); } /** * @notice Combines options for a given endpoint and message type. * @param _eid The endpoint ID. * @param _msgType The OAPP message type. * @param _extraOptions Additional options passed by the caller. * @return options The combination of caller specified options AND enforced options. * * @dev If there is an enforced lzReceive option: * - {gasLimit: 200k, msg.value: 1 ether} AND a caller supplies a lzReceive option: {gasLimit: 100k, msg.value: 0.5 ether} * - The resulting options will be {gasLimit: 300k, msg.value: 1.5 ether} when the message is executed on the remote lzReceive() function. * @dev This presence of duplicated options is handled off-chain in the verifier/executor. */ function combineOptions( uint32 _eid, uint16 _msgType, bytes calldata _extraOptions ) public view virtual returns (bytes memory) { bytes memory enforced = enforcedOptions[_eid][_msgType]; // No enforced options, pass whatever the caller supplied, even if it's empty or legacy type 1/2 options. if (enforced.length == 0) return _extraOptions; // No caller options, return enforced if (_extraOptions.length == 0) return enforced; // @dev If caller provided _extraOptions, must be type 3 as its the ONLY type that can be combined. if (_extraOptions.length >= 2) { _assertOptionsType3(_extraOptions); // @dev Remove the first 2 bytes containing the type from the _extraOptions and combine with enforced. return bytes.concat(enforced, _extraOptions[2:]); } // No valid set of options was found. revert InvalidOptions(_extraOptions); } /** * @dev Internal function to assert that options are of type 3. * @param _options The options to be checked. */ function _assertOptionsType3(bytes memory _options) internal pure virtual { uint16 optionsType; assembly { optionsType := mload(add(_options, 2)) } if (optionsType != OPTION_TYPE_3) revert InvalidOptions(_options); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; // @dev Import the 'MessagingFee' and 'MessagingReceipt' so it's exposed to OApp implementers // solhint-disable-next-line no-unused-import import { OAppSender, MessagingFee, MessagingReceipt } from "./OAppSender.sol"; // @dev Import the 'Origin' so it's exposed to OApp implementers // solhint-disable-next-line no-unused-import import { OAppReceiver, Origin } from "./OAppReceiver.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OApp * @dev Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality. */ abstract contract OApp is OAppSender, OAppReceiver { /** * @dev Constructor to initialize the OApp with the provided endpoint and owner. * @param _endpoint The address of the LOCAL LayerZero endpoint. * @param _delegate The delegate capable of making OApp configurations inside of the endpoint. */ constructor(address _endpoint, address _delegate) OAppCore(_endpoint, _delegate) {} /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol implementation. * @return receiverVersion The version of the OAppReceiver.sol implementation. */ function oAppVersion() public pure virtual override(OAppSender, OAppReceiver) returns (uint64 senderVersion, uint64 receiverVersion) { return (SENDER_VERSION, RECEIVER_VERSION); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IOAppCore, ILayerZeroEndpointV2 } from "./interfaces/IOAppCore.sol"; /** * @title OAppCore * @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations. */ abstract contract OAppCore is IOAppCore, Ownable { // The LayerZero endpoint associated with the given OApp ILayerZeroEndpointV2 public immutable endpoint; // Mapping to store peers associated with corresponding endpoints mapping(uint32 eid => bytes32 peer) public peers; /** * @dev Constructor to initialize the OAppCore with the provided endpoint and delegate. * @param _endpoint The address of the LOCAL Layer Zero endpoint. * @param _delegate The delegate capable of making OApp configurations inside of the endpoint. * * @dev The delegate typically should be set as the owner of the contract. */ constructor(address _endpoint, address _delegate) { endpoint = ILayerZeroEndpointV2(_endpoint); if (_delegate == address(0)) revert InvalidDelegate(); endpoint.setDelegate(_delegate); } /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. * * @dev Only the owner/admin of the OApp can call this function. * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp. * @dev Set this to bytes32(0) to remove the peer address. * @dev Peer is a bytes32 to accommodate non-evm chains. */ function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner { _setPeer(_eid, _peer); } /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. * * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp. * @dev Set this to bytes32(0) to remove the peer address. * @dev Peer is a bytes32 to accommodate non-evm chains. */ function _setPeer(uint32 _eid, bytes32 _peer) internal virtual { peers[_eid] = _peer; emit PeerSet(_eid, _peer); } /** * @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set. * ie. the peer is set to bytes32(0). * @param _eid The endpoint ID. * @return peer The address of the peer associated with the specified endpoint. */ function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) { bytes32 peer = peers[_eid]; if (peer == bytes32(0)) revert NoPeer(_eid); return peer; } /** * @notice Sets the delegate address for the OApp. * @param _delegate The address of the delegate to be set. * * @dev Only the owner/admin of the OApp can call this function. * @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract. */ function setDelegate(address _delegate) public onlyOwner { endpoint.setDelegate(_delegate); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IOAppReceiver, Origin } from "./interfaces/IOAppReceiver.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OAppReceiver * @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers. */ abstract contract OAppReceiver is IOAppReceiver, OAppCore { // Custom error message for when the caller is not the registered endpoint/ error OnlyEndpoint(address addr); // @dev The version of the OAppReceiver implementation. // @dev Version is bumped when changes are made to this contract. uint64 internal constant RECEIVER_VERSION = 2; /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. * * @dev Providing 0 as the default for OAppSender version. Indicates that the OAppSender is not implemented. * ie. this is a RECEIVE only OApp. * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions. */ function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) { return (0, RECEIVER_VERSION); } /** * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint. * @dev _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @dev _message The lzReceive payload. * @param _sender The sender address. * @return isSender Is a valid sender. * * @dev Applications can optionally choose to implement separate composeMsg senders that are NOT the bridging layer. * @dev The default sender IS the OAppReceiver implementer. */ function isComposeMsgSender( Origin calldata /*_origin*/, bytes calldata /*_message*/, address _sender ) public view virtual returns (bool) { return _sender == address(this); } /** * @notice Checks if the path initialization is allowed based on the provided origin. * @param origin The origin information containing the source endpoint and sender address. * @return Whether the path has been initialized. * * @dev This indicates to the endpoint that the OApp has enabled msgs for this particular path to be received. * @dev This defaults to assuming if a peer has been set, its initialized. * Can be overridden by the OApp if there is other logic to determine this. */ function allowInitializePath(Origin calldata origin) public view virtual returns (bool) { return peers[origin.srcEid] == origin.sender; } /** * @notice Retrieves the next nonce for a given source endpoint and sender address. * @dev _srcEid The source endpoint ID. * @dev _sender The sender address. * @return nonce The next nonce. * * @dev The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement. * @dev Is required by the off-chain executor to determine the OApp expects msg execution is ordered. * @dev This is also enforced by the OApp. * @dev By default this is NOT enabled. ie. nextNonce is hardcoded to return 0. */ function nextNonce(uint32 /*_srcEid*/, bytes32 /*_sender*/) public view virtual returns (uint64 nonce) { return 0; } /** * @dev Entry point for receiving messages or packets from the endpoint. * @param _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @param _guid The unique identifier for the received LayerZero message. * @param _message The payload of the received message. * @param _executor The address of the executor for the received message. * @param _extraData Additional arbitrary data provided by the corresponding executor. * * @dev Entry point for receiving msg/packet from the LayerZero endpoint. */ function lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) public payable virtual { // Ensures that only the endpoint can attempt to lzReceive() messages to this OApp. if (address(endpoint) != msg.sender) revert OnlyEndpoint(msg.sender); // Ensure that the sender matches the expected peer for the source endpoint. if (_getPeerOrRevert(_origin.srcEid) != _origin.sender) revert OnlyPeer(_origin.srcEid, _origin.sender); // Call the internal OApp implementation of lzReceive. _lzReceive(_origin, _guid, _message, _executor, _extraData); } /** * @dev Internal function to implement lzReceive logic without needing to copy the basic parameter validation. */ function _lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) internal virtual; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OAppSender * @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint. */ abstract contract OAppSender is OAppCore { using SafeERC20 for IERC20; // Custom error messages error NotEnoughNative(uint256 msgValue); error LzTokenUnavailable(); // @dev The version of the OAppSender implementation. // @dev Version is bumped when changes are made to this contract. uint64 internal constant SENDER_VERSION = 1; /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. * * @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented. * ie. this is a SEND only OApp. * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions */ function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) { return (SENDER_VERSION, 0); } /** * @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation. * @param _dstEid The destination endpoint ID. * @param _message The message payload. * @param _options Additional options for the message. * @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens. * @return fee The calculated MessagingFee for the message. * - nativeFee: The native fee for the message. * - lzTokenFee: The LZ token fee for the message. */ function _quote( uint32 _dstEid, bytes memory _message, bytes memory _options, bool _payInLzToken ) internal view virtual returns (MessagingFee memory fee) { return endpoint.quote( MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken), address(this) ); } /** * @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message. * @param _dstEid The destination endpoint ID. * @param _message The message payload. * @param _options Additional options for the message. * @param _fee The calculated LayerZero fee for the message. * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. * @param _refundAddress The address to receive any excess fee values sent to the endpoint. * @return receipt The receipt for the sent message. * - guid: The unique identifier for the sent message. * - nonce: The nonce of the sent message. * - fee: The LayerZero fee incurred for the message. */ function _lzSend( uint32 _dstEid, bytes memory _message, bytes memory _options, MessagingFee memory _fee, address _refundAddress ) internal virtual returns (MessagingReceipt memory receipt) { // @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint. uint256 messageValue = _payNative(_fee.nativeFee); if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee); return // solhint-disable-next-line check-send-result endpoint.send{ value: messageValue }( MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0), _refundAddress ); } /** * @dev Internal function to pay the native fee associated with the message. * @param _nativeFee The native fee to be paid. * @return nativeFee The amount of native currency paid. * * @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction, * this will need to be overridden because msg.value would contain multiple lzFees. * @dev Should be overridden in the event the LayerZero endpoint requires a different native currency. * @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees. * @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time. */ function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) { if (msg.value != _nativeFee) revert NotEnoughNative(msg.value); return _nativeFee; } /** * @dev Internal function to pay the LZ token fee associated with the message. * @param _lzTokenFee The LZ token fee to be paid. * * @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint. * @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend(). */ function _payLzToken(uint256 _lzTokenFee) internal virtual { // @dev Cannot cache the token because it is not immutable in the endpoint. address lzToken = endpoint.lzToken(); if (lzToken == address(0)) revert LzTokenUnavailable(); // Pay LZ token fee by sending tokens to the endpoint. IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { MessagingReceipt, MessagingFee } from "../../oapp/OAppSender.sol"; /** * @dev Struct representing token parameters for the OFT send() operation. */ struct SendParam { uint32 dstEid; // Destination endpoint ID. bytes32 to; // Recipient address. uint256 amountLD; // Amount to send in local decimals. uint256 minAmountLD; // Minimum amount to send in local decimals. bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message. bytes composeMsg; // The composed message for the send() operation. bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations. } /** * @dev Struct representing OFT limit information. * @dev These amounts can change dynamically and are up the the specific oft implementation. */ struct OFTLimit { uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient. uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient. } /** * @dev Struct representing OFT receipt information. */ struct OFTReceipt { uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals. // @dev In non-default implementations, the amountReceivedLD COULD differ from this value. uint256 amountReceivedLD; // Amount of tokens to be received on the remote side. } /** * @dev Struct representing OFT fee details. * @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI. */ struct OFTFeeDetail { int256 feeAmountLD; // Amount of the fee in local decimals. string description; // Description of the fee. } /** * @title IOFT * @dev Interface for the OftChain (OFT) token. * @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well. * @dev This specific interface ID is '0x02e49c2c'. */ interface IOFT { // Custom error messages error InvalidLocalDecimals(); error SlippageExceeded(uint256 amountLD, uint256 minAmountLD); // Events event OFTSent( bytes32 indexed guid, // GUID of the OFT message. uint32 dstEid, // Destination Endpoint ID. address indexed fromAddress, // Address of the sender on the src chain. uint256 amountSentLD, // Amount of tokens sent in local decimals. uint256 amountReceivedLD // Amount of tokens received in local decimals. ); event OFTReceived( bytes32 indexed guid, // GUID of the OFT message. uint32 srcEid, // Source Endpoint ID. address indexed toAddress, // Address of the recipient on the dst chain. uint256 amountReceivedLD // Amount of tokens received in local decimals. ); /** * @notice Retrieves interfaceID and the version of the OFT. * @return interfaceId The interface ID. * @return version The version. * * @dev interfaceId: This specific interface ID is '0x02e49c2c'. * @dev version: Indicates a cross-chain compatible msg encoding with other OFTs. * @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented. * ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1) */ function oftVersion() external view returns (bytes4 interfaceId, uint64 version); /** * @notice Retrieves the address of the token associated with the OFT. * @return token The address of the ERC20 token implementation. */ function token() external view returns (address); /** * @notice Indicates whether the OFT contract requires approval of the 'token()' to send. * @return requiresApproval Needs approval of the underlying token implementation. * * @dev Allows things like wallet implementers to determine integration requirements, * without understanding the underlying token implementation. */ function approvalRequired() external view returns (bool); /** * @notice Retrieves the shared decimals of the OFT. * @return sharedDecimals The shared decimals of the OFT. */ function sharedDecimals() external view returns (uint8); /** * @notice Provides a quote for OFT-related operations. * @param _sendParam The parameters for the send operation. * @return limit The OFT limit information. * @return oftFeeDetails The details of OFT fees. * @return receipt The OFT receipt information. */ function quoteOFT( SendParam calldata _sendParam ) external view returns (OFTLimit memory, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory); /** * @notice Provides a quote for the send() operation. * @param _sendParam The parameters for the send() operation. * @param _payInLzToken Flag indicating whether the caller is paying in the LZ token. * @return fee The calculated LayerZero messaging fee from the send() operation. * * @dev MessagingFee: LayerZero msg fee * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. */ function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory); /** * @notice Executes the send() operation. * @param _sendParam The parameters for the send operation. * @param _fee The fee information supplied by the caller. * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. * @param _refundAddress The address to receive any excess funds from fees etc. on the src. * @return receipt The LayerZero messaging receipt from the send() operation. * @return oftReceipt The OFT receipt information. * * @dev MessagingReceipt: LayerZero msg receipt * - guid: The unique identifier for the sent message. * - nonce: The nonce of the sent message. * - fee: The LayerZero fee incurred for the message. */ function send( SendParam calldata _sendParam, MessagingFee calldata _fee, address _refundAddress ) external payable returns (MessagingReceipt memory, OFTReceipt memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; library OFTComposeMsgCodec { // Offset constants for decoding composed messages uint8 private constant NONCE_OFFSET = 8; uint8 private constant SRC_EID_OFFSET = 12; uint8 private constant AMOUNT_LD_OFFSET = 44; uint8 private constant COMPOSE_FROM_OFFSET = 76; /** * @dev Encodes a OFT composed message. * @param _nonce The nonce value. * @param _srcEid The source endpoint ID. * @param _amountLD The amount in local decimals. * @param _composeMsg The composed message. * @return _msg The encoded Composed message. */ function encode( uint64 _nonce, uint32 _srcEid, uint256 _amountLD, bytes memory _composeMsg // 0x[composeFrom][composeMsg] ) internal pure returns (bytes memory _msg) { _msg = abi.encodePacked(_nonce, _srcEid, _amountLD, _composeMsg); } /** * @dev Retrieves the nonce from the composed message. * @param _msg The message. * @return The nonce value. */ function nonce(bytes calldata _msg) internal pure returns (uint64) { return uint64(bytes8(_msg[:NONCE_OFFSET])); } /** * @dev Retrieves the source endpoint ID from the composed message. * @param _msg The message. * @return The source endpoint ID. */ function srcEid(bytes calldata _msg) internal pure returns (uint32) { return uint32(bytes4(_msg[NONCE_OFFSET:SRC_EID_OFFSET])); } /** * @dev Retrieves the amount in local decimals from the composed message. * @param _msg The message. * @return The amount in local decimals. */ function amountLD(bytes calldata _msg) internal pure returns (uint256) { return uint256(bytes32(_msg[SRC_EID_OFFSET:AMOUNT_LD_OFFSET])); } /** * @dev Retrieves the composeFrom value from the composed message. * @param _msg The message. * @return The composeFrom value. */ function composeFrom(bytes calldata _msg) internal pure returns (bytes32) { return bytes32(_msg[AMOUNT_LD_OFFSET:COMPOSE_FROM_OFFSET]); } /** * @dev Retrieves the composed message. * @param _msg The message. * @return The composed message. */ function composeMsg(bytes calldata _msg) internal pure returns (bytes memory) { return _msg[COMPOSE_FROM_OFFSET:]; } /** * @dev Converts an address to bytes32. * @param _addr The address to convert. * @return The bytes32 representation of the address. */ function addressToBytes32(address _addr) internal pure returns (bytes32) { return bytes32(uint256(uint160(_addr))); } /** * @dev Converts bytes32 to an address. * @param _b The bytes32 value to convert. * @return The address representation of bytes32. */ function bytes32ToAddress(bytes32 _b) internal pure returns (address) { return address(uint160(uint256(_b))); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; library OFTMsgCodec { // Offset constants for encoding and decoding OFT messages uint8 private constant SEND_TO_OFFSET = 32; uint8 private constant SEND_AMOUNT_SD_OFFSET = 40; /** * @dev Encodes an OFT LayerZero message. * @param _sendTo The recipient address. * @param _amountShared The amount in shared decimals. * @param _composeMsg The composed message. * @return _msg The encoded message. * @return hasCompose A boolean indicating whether the message has a composed payload. */ function encode( bytes32 _sendTo, uint64 _amountShared, bytes memory _composeMsg ) internal view returns (bytes memory _msg, bool hasCompose) { hasCompose = _composeMsg.length > 0; // @dev Remote chains will want to know the composed function caller ie. msg.sender on the src. _msg = hasCompose ? abi.encodePacked(_sendTo, _amountShared, addressToBytes32(msg.sender), _composeMsg) : abi.encodePacked(_sendTo, _amountShared); } /** * @dev Checks if the OFT message is composed. * @param _msg The OFT message. * @return A boolean indicating whether the message is composed. */ function isComposed(bytes calldata _msg) internal pure returns (bool) { return _msg.length > SEND_AMOUNT_SD_OFFSET; } /** * @dev Retrieves the recipient address from the OFT message. * @param _msg The OFT message. * @return The recipient address. */ function sendTo(bytes calldata _msg) internal pure returns (bytes32) { return bytes32(_msg[:SEND_TO_OFFSET]); } /** * @dev Retrieves the amount in shared decimals from the OFT message. * @param _msg The OFT message. * @return The amount in shared decimals. */ function amountSD(bytes calldata _msg) internal pure returns (uint64) { return uint64(bytes8(_msg[SEND_TO_OFFSET:SEND_AMOUNT_SD_OFFSET])); } /** * @dev Retrieves the composed message from the OFT message. * @param _msg The OFT message. * @return The composed message. */ function composeMsg(bytes calldata _msg) internal pure returns (bytes memory) { return _msg[SEND_AMOUNT_SD_OFFSET:]; } /** * @dev Converts an address to bytes32. * @param _addr The address to convert. * @return The bytes32 representation of the address. */ function addressToBytes32(address _addr) internal pure returns (bytes32) { return bytes32(uint256(uint160(_addr))); } /** * @dev Converts bytes32 to an address. * @param _b The bytes32 value to convert. * @return The address representation of bytes32. */ function bytes32ToAddress(bytes32 _b) internal pure returns (address) { return address(uint160(uint256(_b))); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { IOFT, OFTCore } from "./OFTCore.sol"; /** * @title OFT Contract * @dev OFT is an ERC-20 token that extends the functionality of the OFTCore contract. */ abstract contract OFT is OFTCore, ERC20 { /** * @dev Constructor for the OFT contract. * @param _name The name of the OFT. * @param _symbol The symbol of the OFT. * @param _lzEndpoint The LayerZero endpoint address. * @param _delegate The delegate capable of making OApp configurations inside of the endpoint. */ constructor( string memory _name, string memory _symbol, address _lzEndpoint, address _delegate ) ERC20(_name, _symbol) OFTCore(decimals(), _lzEndpoint, _delegate) {} /** * @dev Retrieves the address of the underlying ERC20 implementation. * @return The address of the OFT token. * * @dev In the case of OFT, address(this) and erc20 are the same contract. */ function token() public view returns (address) { return address(this); } /** * @notice Indicates whether the OFT contract requires approval of the 'token()' to send. * @return requiresApproval Needs approval of the underlying token implementation. * * @dev In the case of OFT where the contract IS the token, approval is NOT required. */ function approvalRequired() external pure virtual returns (bool) { return false; } /** * @dev Burns tokens from the sender's specified balance. * @param _from The address to debit the tokens from. * @param _amountLD The amount of tokens to send in local decimals. * @param _minAmountLD The minimum amount to send in local decimals. * @param _dstEid The destination chain ID. * @return amountSentLD The amount sent in local decimals. * @return amountReceivedLD The amount received in local decimals on the remote. */ function _debit( address _from, uint256 _amountLD, uint256 _minAmountLD, uint32 _dstEid ) internal virtual override returns (uint256 amountSentLD, uint256 amountReceivedLD) { (amountSentLD, amountReceivedLD) = _debitView(_amountLD, _minAmountLD, _dstEid); // @dev In NON-default OFT, amountSentLD could be 100, with a 10% fee, the amountReceivedLD amount is 90, // therefore amountSentLD CAN differ from amountReceivedLD. // @dev Default OFT burns on src. _burn(_from, amountSentLD); } /** * @dev Credits tokens to the specified address. * @param _to The address to credit the tokens to. * @param _amountLD The amount of tokens to credit in local decimals. * @dev _srcEid The source chain ID. * @return amountReceivedLD The amount of tokens ACTUALLY received in local decimals. */ function _credit( address _to, uint256 _amountLD, uint32 /*_srcEid*/ ) internal virtual override returns (uint256 amountReceivedLD) { // @dev Default OFT mints on dst. _mint(_to, _amountLD); // @dev In the case of NON-default OFT, the _amountLD MIGHT not be == amountReceivedLD. return _amountLD; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { OApp, Origin } from "../oapp/OApp.sol"; import { OAppOptionsType3 } from "../oapp/libs/OAppOptionsType3.sol"; import { IOAppMsgInspector } from "../oapp/interfaces/IOAppMsgInspector.sol"; import { OAppPreCrimeSimulator } from "../precrime/OAppPreCrimeSimulator.sol"; import { IOFT, SendParam, OFTLimit, OFTReceipt, OFTFeeDetail, MessagingReceipt, MessagingFee } from "./interfaces/IOFT.sol"; import { OFTMsgCodec } from "./libs/OFTMsgCodec.sol"; import { OFTComposeMsgCodec } from "./libs/OFTComposeMsgCodec.sol"; /** * @title OFTCore * @dev Abstract contract for the OftChain (OFT) token. */ abstract contract OFTCore is IOFT, OApp, OAppPreCrimeSimulator, OAppOptionsType3 { using OFTMsgCodec for bytes; using OFTMsgCodec for bytes32; // @notice Provides a conversion rate when swapping between denominations of SD and LD // - shareDecimals == SD == shared Decimals // - localDecimals == LD == local decimals // @dev Considers that tokens have different decimal amounts on various chains. // @dev eg. // For a token // - locally with 4 decimals --> 1.2345 => uint(12345) // - remotely with 2 decimals --> 1.23 => uint(123) // - The conversion rate would be 10 ** (4 - 2) = 100 // @dev If you want to send 1.2345 -> (uint 12345), you CANNOT represent that value on the remote, // you can only display 1.23 -> uint(123). // @dev To preserve the dust that would otherwise be lost on that conversion, // we need to unify a denomination that can be represented on ALL chains inside of the OFT mesh uint256 public immutable decimalConversionRate; // @notice Msg types that are used to identify the various OFT operations. // @dev This can be extended in child contracts for non-default oft operations // @dev These values are used in things like combineOptions() in OAppOptionsType3.sol. uint16 public constant SEND = 1; uint16 public constant SEND_AND_CALL = 2; // Address of an optional contract to inspect both 'message' and 'options' address public msgInspector; event MsgInspectorSet(address inspector); /** * @dev Constructor. * @param _localDecimals The decimals of the token on the local chain (this chain). * @param _endpoint The address of the LayerZero endpoint. * @param _delegate The delegate capable of making OApp configurations inside of the endpoint. */ constructor(uint8 _localDecimals, address _endpoint, address _delegate) OApp(_endpoint, _delegate) { if (_localDecimals < sharedDecimals()) revert InvalidLocalDecimals(); decimalConversionRate = 10 ** (_localDecimals - sharedDecimals()); } /** * @notice Retrieves interfaceID and the version of the OFT. * @return interfaceId The interface ID. * @return version The version. * * @dev interfaceId: This specific interface ID is '0x02e49c2c'. * @dev version: Indicates a cross-chain compatible msg encoding with other OFTs. * @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented. * ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1) */ function oftVersion() external pure virtual returns (bytes4 interfaceId, uint64 version) { return (type(IOFT).interfaceId, 1); } /** * @dev Retrieves the shared decimals of the OFT. * @return The shared decimals of the OFT. * * @dev Sets an implicit cap on the amount of tokens, over uint64.max() will need some sort of outbound cap / totalSupply cap * Lowest common decimal denominator between chains. * Defaults to 6 decimal places to provide up to 18,446,744,073,709.551615 units (max uint64). * For tokens exceeding this totalSupply(), they will need to override the sharedDecimals function with something smaller. * ie. 4 sharedDecimals would be 1,844,674,407,370,955.1615 */ function sharedDecimals() public view virtual returns (uint8) { return 6; } /** * @dev Sets the message inspector address for the OFT. * @param _msgInspector The address of the message inspector. * * @dev This is an optional contract that can be used to inspect both 'message' and 'options'. * @dev Set it to address(0) to disable it, or set it to a contract address to enable it. */ function setMsgInspector(address _msgInspector) public virtual onlyOwner { msgInspector = _msgInspector; emit MsgInspectorSet(_msgInspector); } /** * @notice Provides a quote for OFT-related operations. * @param _sendParam The parameters for the send operation. * @return oftLimit The OFT limit information. * @return oftFeeDetails The details of OFT fees. * @return oftReceipt The OFT receipt information. */ function quoteOFT( SendParam calldata _sendParam ) external view virtual returns (OFTLimit memory oftLimit, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory oftReceipt) { uint256 minAmountLD = 0; // Unused in the default implementation. uint256 maxAmountLD = type(uint64).max; // Unused in the default implementation. oftLimit = OFTLimit(minAmountLD, maxAmountLD); // Unused in the default implementation; reserved for future complex fee details. oftFeeDetails = new OFTFeeDetail[](0); // @dev This is the same as the send() operation, but without the actual send. // - amountSentLD is the amount in local decimals that would be sent from the sender. // - amountReceivedLD is the amount in local decimals that will be credited to the recipient on the remote OFT instance. // @dev The amountSentLD MIGHT not equal the amount the user actually receives. HOWEVER, the default does. (uint256 amountSentLD, uint256 amountReceivedLD) = _debitView( _sendParam.amountLD, _sendParam.minAmountLD, _sendParam.dstEid ); oftReceipt = OFTReceipt(amountSentLD, amountReceivedLD); } /** * @notice Provides a quote for the send() operation. * @param _sendParam The parameters for the send() operation. * @param _payInLzToken Flag indicating whether the caller is paying in the LZ token. * @return msgFee The calculated LayerZero messaging fee from the send() operation. * * @dev MessagingFee: LayerZero msg fee * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. */ function quoteSend( SendParam calldata _sendParam, bool _payInLzToken ) external view virtual returns (MessagingFee memory msgFee) { // @dev mock the amount to receive, this is the same operation used in the send(). // The quote is as similar as possible to the actual send() operation. (, uint256 amountReceivedLD) = _debitView(_sendParam.amountLD, _sendParam.minAmountLD, _sendParam.dstEid); // @dev Builds the options and OFT message to quote in the endpoint. (bytes memory message, bytes memory options) = _buildMsgAndOptions(_sendParam, amountReceivedLD); // @dev Calculates the LayerZero fee for the send() operation. return _quote(_sendParam.dstEid, message, options, _payInLzToken); } /** * @dev Executes the send operation. * @param _sendParam The parameters for the send operation. * @param _fee The calculated fee for the send() operation. * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. * @param _refundAddress The address to receive any excess funds. * @return msgReceipt The receipt for the send operation. * @return oftReceipt The OFT receipt information. * * @dev MessagingReceipt: LayerZero msg receipt * - guid: The unique identifier for the sent message. * - nonce: The nonce of the sent message. * - fee: The LayerZero fee incurred for the message. */ function send( SendParam calldata _sendParam, MessagingFee calldata _fee, address _refundAddress ) external payable virtual returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) { // @dev Applies the token transfers regarding this send() operation. // - amountSentLD is the amount in local decimals that was ACTUALLY sent/debited from the sender. // - amountReceivedLD is the amount in local decimals that will be received/credited to the recipient on the remote OFT instance. (uint256 amountSentLD, uint256 amountReceivedLD) = _debit( msg.sender, _sendParam.amountLD, _sendParam.minAmountLD, _sendParam.dstEid ); // @dev Builds the options and OFT message to quote in the endpoint. (bytes memory message, bytes memory options) = _buildMsgAndOptions(_sendParam, amountReceivedLD); // @dev Sends the message to the LayerZero endpoint and returns the LayerZero msg receipt. msgReceipt = _lzSend(_sendParam.dstEid, message, options, _fee, _refundAddress); // @dev Formulate the OFT receipt. oftReceipt = OFTReceipt(amountSentLD, amountReceivedLD); emit OFTSent(msgReceipt.guid, _sendParam.dstEid, msg.sender, amountSentLD, amountReceivedLD); } /** * @dev Internal function to build the message and options. * @param _sendParam The parameters for the send() operation. * @param _amountLD The amount in local decimals. * @return message The encoded message. * @return options The encoded options. */ function _buildMsgAndOptions( SendParam calldata _sendParam, uint256 _amountLD ) internal view virtual returns (bytes memory message, bytes memory options) { bool hasCompose; // @dev This generated message has the msg.sender encoded into the payload so the remote knows who the caller is. (message, hasCompose) = OFTMsgCodec.encode( _sendParam.to, _toSD(_amountLD), // @dev Must be include a non empty bytes if you want to compose, EVEN if you dont need it on the remote. // EVEN if you dont require an arbitrary payload to be sent... eg. '0x01' _sendParam.composeMsg ); // @dev Change the msg type depending if its composed or not. uint16 msgType = hasCompose ? SEND_AND_CALL : SEND; // @dev Combine the callers _extraOptions with the enforced options via the OAppOptionsType3. options = combineOptions(_sendParam.dstEid, msgType, _sendParam.extraOptions); // @dev Optionally inspect the message and options depending if the OApp owner has set a msg inspector. // @dev If it fails inspection, needs to revert in the implementation. ie. does not rely on return boolean if (msgInspector != address(0)) IOAppMsgInspector(msgInspector).inspect(message, options); } /** * @dev Internal function to handle the receive on the LayerZero endpoint. * @param _origin The origin information. * - srcEid: The source chain endpoint ID. * - sender: The sender address from the src chain. * - nonce: The nonce of the LayerZero message. * @param _guid The unique identifier for the received LayerZero message. * @param _message The encoded message. * @dev _executor The address of the executor. * @dev _extraData Additional data. */ function _lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address /*_executor*/, // @dev unused in the default implementation. bytes calldata /*_extraData*/ // @dev unused in the default implementation. ) internal virtual override { // @dev The src sending chain doesnt know the address length on this chain (potentially non-evm) // Thus everything is bytes32() encoded in flight. address toAddress = _message.sendTo().bytes32ToAddress(); // @dev Credit the amountLD to the recipient and return the ACTUAL amount the recipient received in local decimals uint256 amountReceivedLD = _credit(toAddress, _toLD(_message.amountSD()), _origin.srcEid); if (_message.isComposed()) { // @dev Proprietary composeMsg format for the OFT. bytes memory composeMsg = OFTComposeMsgCodec.encode( _origin.nonce, _origin.srcEid, amountReceivedLD, _message.composeMsg() ); // @dev Stores the lzCompose payload that will be executed in a separate tx. // Standardizes functionality for executing arbitrary contract invocation on some non-evm chains. // @dev The off-chain executor will listen and process the msg based on the src-chain-callers compose options passed. // @dev The index is used when a OApp needs to compose multiple msgs on lzReceive. // For default OFT implementation there is only 1 compose msg per lzReceive, thus its always 0. endpoint.sendCompose(toAddress, _guid, 0 /* the index of the composed message*/, composeMsg); } emit OFTReceived(_guid, _origin.srcEid, toAddress, amountReceivedLD); } /** * @dev Internal function to handle the OAppPreCrimeSimulator simulated receive. * @param _origin The origin information. * - srcEid: The source chain endpoint ID. * - sender: The sender address from the src chain. * - nonce: The nonce of the LayerZero message. * @param _guid The unique identifier for the received LayerZero message. * @param _message The LayerZero message. * @param _executor The address of the off-chain executor. * @param _extraData Arbitrary data passed by the msg executor. * * @dev Enables the preCrime simulator to mock sending lzReceive() messages, * routes the msg down from the OAppPreCrimeSimulator, and back up to the OAppReceiver. */ function _lzReceiveSimulate( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) internal virtual override { _lzReceive(_origin, _guid, _message, _executor, _extraData); } /** * @dev Check if the peer is considered 'trusted' by the OApp. * @param _eid The endpoint ID to check. * @param _peer The peer to check. * @return Whether the peer passed is considered 'trusted' by the OApp. * * @dev Enables OAppPreCrimeSimulator to check whether a potential Inbound Packet is from a trusted source. */ function isPeer(uint32 _eid, bytes32 _peer) public view virtual override returns (bool) { return peers[_eid] == _peer; } /** * @dev Internal function to remove dust from the given local decimal amount. * @param _amountLD The amount in local decimals. * @return amountLD The amount after removing dust. * * @dev Prevents the loss of dust when moving amounts between chains with different decimals. * @dev eg. uint(123) with a conversion rate of 100 becomes uint(100). */ function _removeDust(uint256 _amountLD) internal view virtual returns (uint256 amountLD) { return (_amountLD / decimalConversionRate) * decimalConversionRate; } /** * @dev Internal function to convert an amount from shared decimals into local decimals. * @param _amountSD The amount in shared decimals. * @return amountLD The amount in local decimals. */ function _toLD(uint64 _amountSD) internal view virtual returns (uint256 amountLD) { return _amountSD * decimalConversionRate; } /** * @dev Internal function to convert an amount from local decimals into shared decimals. * @param _amountLD The amount in local decimals. * @return amountSD The amount in shared decimals. */ function _toSD(uint256 _amountLD) internal view virtual returns (uint64 amountSD) { return uint64(_amountLD / decimalConversionRate); } /** * @dev Internal function to mock the amount mutation from a OFT debit() operation. * @param _amountLD The amount to send in local decimals. * @param _minAmountLD The minimum amount to send in local decimals. * @dev _dstEid The destination endpoint ID. * @return amountSentLD The amount sent, in local decimals. * @return amountReceivedLD The amount to be received on the remote chain, in local decimals. * * @dev This is where things like fees would be calculated and deducted from the amount to be received on the remote. */ function _debitView( uint256 _amountLD, uint256 _minAmountLD, uint32 /*_dstEid*/ ) internal view virtual returns (uint256 amountSentLD, uint256 amountReceivedLD) { // @dev Remove the dust so nothing is lost on the conversion between chains with different decimals for the token. amountSentLD = _removeDust(_amountLD); // @dev The amount to send is the same as amount received in the default implementation. amountReceivedLD = amountSentLD; // @dev Check for slippage. if (amountReceivedLD < _minAmountLD) { revert SlippageExceeded(amountReceivedLD, _minAmountLD); } } /** * @dev Internal function to perform a debit operation. * @param _from The address to debit. * @param _amountLD The amount to send in local decimals. * @param _minAmountLD The minimum amount to send in local decimals. * @param _dstEid The destination endpoint ID. * @return amountSentLD The amount sent in local decimals. * @return amountReceivedLD The amount received in local decimals on the remote. * * @dev Defined here but are intended to be overriden depending on the OFT implementation. * @dev Depending on OFT implementation the _amountLD could differ from the amountReceivedLD. */ function _debit( address _from, uint256 _amountLD, uint256 _minAmountLD, uint32 _dstEid ) internal virtual returns (uint256 amountSentLD, uint256 amountReceivedLD); /** * @dev Internal function to perform a credit operation. * @param _to The address to credit. * @param _amountLD The amount to credit in local decimals. * @param _srcEid The source endpoint ID. * @return amountReceivedLD The amount ACTUALLY received in local decimals. * * @dev Defined here but are intended to be overriden depending on the OFT implementation. * @dev Depending on OFT implementation the _amountLD could differ from the amountReceivedLD. */ function _credit( address _to, uint256 _amountLD, uint32 _srcEid ) internal virtual returns (uint256 amountReceivedLD); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; // @dev Import the Origin so it's exposed to OAppPreCrimeSimulator implementers. // solhint-disable-next-line no-unused-import import { InboundPacket, Origin } from "../libs/Packet.sol"; /** * @title IOAppPreCrimeSimulator Interface * @dev Interface for the preCrime simulation functionality in an OApp. */ interface IOAppPreCrimeSimulator { // @dev simulation result used in PreCrime implementation error SimulationResult(bytes result); error OnlySelf(); /** * @dev Emitted when the preCrime contract address is set. * @param preCrimeAddress The address of the preCrime contract. */ event PreCrimeSet(address preCrimeAddress); /** * @dev Retrieves the address of the preCrime contract implementation. * @return The address of the preCrime contract. */ function preCrime() external view returns (address); /** * @dev Retrieves the address of the OApp contract. * @return The address of the OApp contract. */ function oApp() external view returns (address); /** * @dev Sets the preCrime contract address. * @param _preCrime The address of the preCrime contract. */ function setPreCrime(address _preCrime) external; /** * @dev Mocks receiving a packet, then reverts with a series of data to infer the state/result. * @param _packets An array of LayerZero InboundPacket objects representing received packets. */ function lzReceiveAndRevert(InboundPacket[] calldata _packets) external payable; /** * @dev checks if the specified peer is considered 'trusted' by the OApp. * @param _eid The endpoint Id to check. * @param _peer The peer to check. * @return Whether the peer passed is considered 'trusted' by the OApp. */ function isPeer(uint32 _eid, bytes32 _peer) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; struct PreCrimePeer { uint32 eid; bytes32 preCrime; bytes32 oApp; } // TODO not done yet interface IPreCrime { error OnlyOffChain(); // for simulate() error PacketOversize(uint256 max, uint256 actual); error PacketUnsorted(); error SimulationFailed(bytes reason); // for preCrime() error SimulationResultNotFound(uint32 eid); error InvalidSimulationResult(uint32 eid, bytes reason); error CrimeFound(bytes crime); function getConfig(bytes[] calldata _packets, uint256[] calldata _packetMsgValues) external returns (bytes memory); function simulate( bytes[] calldata _packets, uint256[] calldata _packetMsgValues ) external payable returns (bytes memory); function buildSimulationResult() external view returns (bytes memory); function preCrime( bytes[] calldata _packets, uint256[] calldata _packetMsgValues, bytes[] calldata _simulations ) external; function version() external view returns (uint64 major, uint8 minor); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol"; /** * @title InboundPacket * @dev Structure representing an inbound packet received by the contract. */ struct InboundPacket { Origin origin; // Origin information of the packet. uint32 dstEid; // Destination endpointId of the packet. address receiver; // Receiver address for the packet. bytes32 guid; // Unique identifier of the packet. uint256 value; // msg.value of the packet. address executor; // Executor address for the packet. bytes message; // Message payload of the packet. bytes extraData; // Additional arbitrary data for the packet. } /** * @title PacketDecoder * @dev Library for decoding LayerZero packets. */ library PacketDecoder { using PacketV1Codec for bytes; /** * @dev Decode an inbound packet from the given packet data. * @param _packet The packet data to decode. * @return packet An InboundPacket struct representing the decoded packet. */ function decode(bytes calldata _packet) internal pure returns (InboundPacket memory packet) { packet.origin = Origin(_packet.srcEid(), _packet.sender(), _packet.nonce()); packet.dstEid = _packet.dstEid(); packet.receiver = _packet.receiverB20(); packet.guid = _packet.guid(); packet.message = _packet.message(); } /** * @dev Decode multiple inbound packets from the given packet data and associated message values. * @param _packets An array of packet data to decode. * @param _packetMsgValues An array of associated message values for each packet. * @return packets An array of InboundPacket structs representing the decoded packets. */ function decode( bytes[] calldata _packets, uint256[] memory _packetMsgValues ) internal pure returns (InboundPacket[] memory packets) { packets = new InboundPacket[](_packets.length); for (uint256 i = 0; i < _packets.length; i++) { bytes calldata packet = _packets[i]; packets[i] = PacketDecoder.decode(packet); // @dev Allows the verifier to specify the msg.value that gets passed in lzReceive. packets[i].value = _packetMsgValues[i]; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IPreCrime } from "./interfaces/IPreCrime.sol"; import { IOAppPreCrimeSimulator, InboundPacket, Origin } from "./interfaces/IOAppPreCrimeSimulator.sol"; /** * @title OAppPreCrimeSimulator * @dev Abstract contract serving as the base for preCrime simulation functionality in an OApp. */ abstract contract OAppPreCrimeSimulator is IOAppPreCrimeSimulator, Ownable { // The address of the preCrime implementation. address public preCrime; /** * @dev Retrieves the address of the OApp contract. * @return The address of the OApp contract. * * @dev The simulator contract is the base contract for the OApp by default. * @dev If the simulator is a separate contract, override this function. */ function oApp() external view virtual returns (address) { return address(this); } /** * @dev Sets the preCrime contract address. * @param _preCrime The address of the preCrime contract. */ function setPreCrime(address _preCrime) public virtual onlyOwner { preCrime = _preCrime; emit PreCrimeSet(_preCrime); } /** * @dev Interface for pre-crime simulations. Always reverts at the end with the simulation results. * @param _packets An array of InboundPacket objects representing received packets to be delivered. * * @dev WARNING: MUST revert at the end with the simulation results. * @dev Gives the preCrime implementation the ability to mock sending packets to the lzReceive function, * WITHOUT actually executing them. */ function lzReceiveAndRevert(InboundPacket[] calldata _packets) public payable virtual { for (uint256 i = 0; i < _packets.length; i++) { InboundPacket calldata packet = _packets[i]; // Ignore packets that are not from trusted peers. if (!isPeer(packet.origin.srcEid, packet.origin.sender)) continue; // @dev Because a verifier is calling this function, it doesnt have access to executor params: // - address _executor // - bytes calldata _extraData // preCrime will NOT work for OApps that rely on these two parameters inside of their _lzReceive(). // They are instead stubbed to default values, address(0) and bytes("") // @dev Calling this.lzReceiveSimulate removes ability for assembly return 0 callstack exit, // which would cause the revert to be ignored. this.lzReceiveSimulate{ value: packet.value }( packet.origin, packet.guid, packet.message, packet.executor, packet.extraData ); } // @dev Revert with the simulation results. msg.sender must implement IPreCrime.buildSimulationResult(). revert SimulationResult(IPreCrime(msg.sender).buildSimulationResult()); } /** * @dev Is effectively an internal function because msg.sender must be address(this). * Allows resetting the call stack for 'internal' calls. * @param _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @param _guid The unique identifier of the packet. * @param _message The message payload of the packet. * @param _executor The executor address for the packet. * @param _extraData Additional data for the packet. */ function lzReceiveSimulate( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) external payable virtual { // @dev Ensure ONLY can be called 'internally'. if (msg.sender != address(this)) revert OnlySelf(); _lzReceiveSimulate(_origin, _guid, _message, _executor, _extraData); } /** * @dev Internal function to handle the OAppPreCrimeSimulator simulated receive. * @param _origin The origin information. * - srcEid: The source chain endpoint ID. * - sender: The sender address from the src chain. * - nonce: The nonce of the LayerZero message. * @param _guid The GUID of the LayerZero message. * @param _message The LayerZero message. * @param _executor The address of the off-chain executor. * @param _extraData Arbitrary data passed by the msg executor. * * @dev Enables the preCrime simulator to mock sending lzReceive() messages, * routes the msg down from the OAppPreCrimeSimulator, and back up to the OAppReceiver. */ function _lzReceiveSimulate( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) internal virtual; /** * @dev checks if the specified peer is considered 'trusted' by the OApp. * @param _eid The endpoint Id to check. * @param _peer The peer to check. * @return Whether the peer passed is considered 'trusted' by the OApp. */ function isPeer(uint32 _eid, bytes32 _peer) public view virtual returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { IMessageLibManager } from "./IMessageLibManager.sol"; import { IMessagingComposer } from "./IMessagingComposer.sol"; import { IMessagingChannel } from "./IMessagingChannel.sol"; import { IMessagingContext } from "./IMessagingContext.sol"; struct MessagingParams { uint32 dstEid; bytes32 receiver; bytes message; bytes options; bool payInLzToken; } struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; } struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; } struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; } interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext { event PacketSent(bytes encodedPayload, bytes options, address sendLibrary); event PacketVerified(Origin origin, address receiver, bytes32 payloadHash); event PacketDelivered(Origin origin, address receiver); event LzReceiveAlert( address indexed receiver, address indexed executor, Origin origin, bytes32 guid, uint256 gas, uint256 value, bytes message, bytes extraData, bytes reason ); event LzTokenSet(address token); event DelegateSet(address sender, address delegate); function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory); function send( MessagingParams calldata _params, address _refundAddress ) external payable returns (MessagingReceipt memory); function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external; function verifiable(Origin calldata _origin, address _receiver) external view returns (bool); function initializable(Origin calldata _origin, address _receiver) external view returns (bool); function lzReceive( Origin calldata _origin, address _receiver, bytes32 _guid, bytes calldata _message, bytes calldata _extraData ) external payable; // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external; function setLzToken(address _lzToken) external; function lzToken() external view returns (address); function nativeToken() external view returns (address); function setDelegate(address _delegate) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { Origin } from "./ILayerZeroEndpointV2.sol"; interface ILayerZeroReceiver { function allowInitializePath(Origin calldata _origin) external view returns (bool); function nextNonce(uint32 _eid, bytes32 _sender) external view returns (uint64); function lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { SetConfigParam } from "./IMessageLibManager.sol"; enum MessageLibType { Send, Receive, SendAndReceive } interface IMessageLib is IERC165 { function setConfig(address _oapp, SetConfigParam[] calldata _config) external; function getConfig(uint32 _eid, address _oapp, uint32 _configType) external view returns (bytes memory config); function isSupportedEid(uint32 _eid) external view returns (bool); // message libs of same major version are compatible function version() external view returns (uint64 major, uint8 minor, uint8 endpointVersion); function messageLibType() external view returns (MessageLibType); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; struct SetConfigParam { uint32 eid; uint32 configType; bytes config; } interface IMessageLibManager { struct Timeout { address lib; uint256 expiry; } event LibraryRegistered(address newLib); event DefaultSendLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry); event SendLibrarySet(address sender, uint32 eid, address newLib); event ReceiveLibrarySet(address receiver, uint32 eid, address newLib); event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout); function registerLibrary(address _lib) external; function isRegisteredLibrary(address _lib) external view returns (bool); function getRegisteredLibraries() external view returns (address[] memory); function setDefaultSendLibrary(uint32 _eid, address _newLib) external; function defaultSendLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _timeout) external; function defaultReceiveLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external; function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry); function isSupportedEid(uint32 _eid) external view returns (bool); function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool); /// ------------------- OApp interfaces ------------------- function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external; function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib); function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool); function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external; function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault); function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _gracePeriod) external; function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry); function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external; function getConfig( address _oapp, address _lib, uint32 _eid, uint32 _configType ) external view returns (bytes memory config); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingChannel { event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce); event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash); event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash); function eid() external view returns (uint32); // this is an emergency function if a message cannot be verified for some reasons // required to provide _nextNonce to avoid race condition function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external; function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external; function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external; function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32); function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64); function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64); function inboundPayloadHash( address _receiver, uint32 _srcEid, bytes32 _sender, uint64 _nonce ) external view returns (bytes32); function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingComposer { event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message); event ComposeDelivered(address from, address to, bytes32 guid, uint16 index); event LzComposeAlert( address indexed from, address indexed to, address indexed executor, bytes32 guid, uint16 index, uint256 gas, uint256 value, bytes message, bytes extraData, bytes reason ); function composeQueue( address _from, address _to, bytes32 _guid, uint16 _index ) external view returns (bytes32 messageHash); function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external; function lzCompose( address _from, address _to, bytes32 _guid, uint16 _index, bytes calldata _message, bytes calldata _extraData ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingContext { function isSendingMessage() external view returns (bool); function getSendContext() external view returns (uint32 dstEid, address sender); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { MessagingFee } from "./ILayerZeroEndpointV2.sol"; import { IMessageLib } from "./IMessageLib.sol"; struct Packet { uint64 nonce; uint32 srcEid; address sender; uint32 dstEid; bytes32 receiver; bytes32 guid; bytes message; } interface ISendLib is IMessageLib { function send( Packet calldata _packet, bytes calldata _options, bool _payInLzToken ) external returns (MessagingFee memory, bytes memory encodedPacket); function quote( Packet calldata _packet, bytes calldata _options, bool _payInLzToken ) external view returns (MessagingFee memory); function setTreasury(address _treasury) external; function withdrawFee(address _to, uint256 _amount) external; function withdrawLzTokenFee(address _lzToken, address _to, uint256 _amount) external; }
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; library AddressCast { error AddressCast_InvalidSizeForAddress(); error AddressCast_InvalidAddress(); function toBytes32(bytes calldata _addressBytes) internal pure returns (bytes32 result) { if (_addressBytes.length > 32) revert AddressCast_InvalidAddress(); result = bytes32(_addressBytes); unchecked { uint256 offset = 32 - _addressBytes.length; result = result >> (offset * 8); } } function toBytes32(address _address) internal pure returns (bytes32 result) { result = bytes32(uint256(uint160(_address))); } function toBytes(bytes32 _addressBytes32, uint256 _size) internal pure returns (bytes memory result) { if (_size == 0 || _size > 32) revert AddressCast_InvalidSizeForAddress(); result = new bytes(_size); unchecked { uint256 offset = 256 - _size * 8; assembly { mstore(add(result, 32), shl(offset, _addressBytes32)) } } } function toAddress(bytes32 _addressBytes32) internal pure returns (address result) { result = address(uint160(uint256(_addressBytes32))); } function toAddress(bytes calldata _addressBytes) internal pure returns (address result) { if (_addressBytes.length != 20) revert AddressCast_InvalidAddress(); result = address(bytes20(_addressBytes)); } }
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; import { Packet } from "../../interfaces/ISendLib.sol"; import { AddressCast } from "../../libs/AddressCast.sol"; library PacketV1Codec { using AddressCast for address; using AddressCast for bytes32; uint8 internal constant PACKET_VERSION = 1; // header (version + nonce + path) // version uint256 private constant PACKET_VERSION_OFFSET = 0; // nonce uint256 private constant NONCE_OFFSET = 1; // path uint256 private constant SRC_EID_OFFSET = 9; uint256 private constant SENDER_OFFSET = 13; uint256 private constant DST_EID_OFFSET = 45; uint256 private constant RECEIVER_OFFSET = 49; // payload (guid + message) uint256 private constant GUID_OFFSET = 81; // keccak256(nonce + path) uint256 private constant MESSAGE_OFFSET = 113; function encode(Packet memory _packet) internal pure returns (bytes memory encodedPacket) { encodedPacket = abi.encodePacked( PACKET_VERSION, _packet.nonce, _packet.srcEid, _packet.sender.toBytes32(), _packet.dstEid, _packet.receiver, _packet.guid, _packet.message ); } function encodePacketHeader(Packet memory _packet) internal pure returns (bytes memory) { return abi.encodePacked( PACKET_VERSION, _packet.nonce, _packet.srcEid, _packet.sender.toBytes32(), _packet.dstEid, _packet.receiver ); } function encodePayload(Packet memory _packet) internal pure returns (bytes memory) { return abi.encodePacked(_packet.guid, _packet.message); } function header(bytes calldata _packet) internal pure returns (bytes calldata) { return _packet[0:GUID_OFFSET]; } function version(bytes calldata _packet) internal pure returns (uint8) { return uint8(bytes1(_packet[PACKET_VERSION_OFFSET:NONCE_OFFSET])); } function nonce(bytes calldata _packet) internal pure returns (uint64) { return uint64(bytes8(_packet[NONCE_OFFSET:SRC_EID_OFFSET])); } function srcEid(bytes calldata _packet) internal pure returns (uint32) { return uint32(bytes4(_packet[SRC_EID_OFFSET:SENDER_OFFSET])); } function sender(bytes calldata _packet) internal pure returns (bytes32) { return bytes32(_packet[SENDER_OFFSET:DST_EID_OFFSET]); } function senderAddressB20(bytes calldata _packet) internal pure returns (address) { return sender(_packet).toAddress(); } function dstEid(bytes calldata _packet) internal pure returns (uint32) { return uint32(bytes4(_packet[DST_EID_OFFSET:RECEIVER_OFFSET])); } function receiver(bytes calldata _packet) internal pure returns (bytes32) { return bytes32(_packet[RECEIVER_OFFSET:GUID_OFFSET]); } function receiverB20(bytes calldata _packet) internal pure returns (address) { return receiver(_packet).toAddress(); } function guid(bytes calldata _packet) internal pure returns (bytes32) { return bytes32(_packet[GUID_OFFSET:MESSAGE_OFFSET]); } function message(bytes calldata _packet) internal pure returns (bytes calldata) { return bytes(_packet[MESSAGE_OFFSET:]); } function payload(bytes calldata _packet) internal pure returns (bytes calldata) { return bytes(_packet[GUID_OFFSET:]); } function payloadHash(bytes calldata _packet) internal pure returns (bytes32) { return keccak256(payload(_packet)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * 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 Ownable is Context { address private _owner; /** * @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. */ constructor(address initialOwner) { 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) { 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 { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.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 ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `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) { 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 { 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 { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.20; import {IERC20Permit} from "./IERC20Permit.sol"; import {ERC20} from "../ERC20.sol"; import {ECDSA} from "../../../utils/cryptography/ECDSA.sol"; import {EIP712} from "../../../utils/cryptography/EIP712.sol"; import {Nonces} from "../../../utils/Nonces.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces { bytes32 private constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Permit deadline has expired. */ error ERC2612ExpiredSignature(uint256 deadline); /** * @dev Mismatched signature. */ error ERC2612InvalidSigner(address signer, address owner); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @inheritdoc IERC20Permit */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { if (block.timestamp > deadline) { revert ERC2612ExpiredSignature(deadline); } bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); if (signer != owner) { revert ERC2612InvalidSigner(signer, owner); } _approve(owner, spender, value); } /** * @inheritdoc IERC20Permit */ function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) { return super.nonces(owner); } /** * @inheritdoc IERC20Permit */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view virtual returns (bytes32) { return _domainSeparatorV4(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// 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.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "./MessageHashUtils.sol"; import {ShortStrings, ShortString} from "../ShortStrings.sol"; import {IERC5267} from "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) pragma solidity ^0.8.20; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract Nonces { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); mapping(address account => uint256) private _nonces; /** * @dev Returns the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { return _nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return _nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using * {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated 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) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Emitted when the owner of the factory is changed /// @param oldOwner The owner before the owner was changed /// @param newOwner The owner after the owner was changed event OwnerChanged(address indexed oldOwner, address indexed newOwner); /// @notice Emitted when a pool is created /// @param token0 The first token of the pool by address sort order /// @param token1 The second token of the pool by address sort order /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param pool The address of the created pool event PoolCreated( address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool ); /// @notice Emitted when a new fee amount is enabled for pool creation via the factory /// @param fee The enabled fee, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); /// @notice Returns the current owner of the factory /// @dev Can be changed by the current owner via setOwner /// @return The address of the factory owner function owner() external view returns (address); /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee /// @return The tick spacing function feeAmountTickSpacing(uint24 fee) external view returns (int24); /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param fee The desired fee for the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments /// are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); /// @notice Updates the owner of the factory /// @dev Must be called by the current owner /// @param _owner The new owner of the factory function setOwner(address _owner) external; /// @notice Enables a fee amount with the given tickSpacing /// @dev Fee amounts may never be removed once enabled /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, int24 tickSpacing) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import '@openzeppelin/contracts/utils/Context.sol'; import '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol'; import './interfaces/ILPAdapter.sol'; contract GameTheoryRewards is Context { uint256 constant P = FixedPoint96.Q96; uint256 public immutable CREATED; address public immutable TOKEN; uint256 public immutable FIRST_CLAIM_DELAY; uint256 public immutable MIN_LOCKUP_TIME; uint256 public totalUsers; uint256 public totalShares; struct Reward { uint256 cached; uint256 excluded; uint256 realized; } mapping(address => uint256) public shares; mapping(address => uint256) public lastClaimAmt; mapping(address => uint256) public lastClaimTime; mapping(address => Reward) public rewards; uint256 _totalPerShare; uint256 public totalDistributed; uint256 public totalDepositedGross; uint256 public totalDepositedNet; event AddShares( address indexed user, uint256 amount, uint256 userCached, uint256 userExcluded ); event RemoveShares( address indexed user, uint256 amount, uint256 userCached, uint256 userExcluded ); event CacheReward( address indexed user, uint256 newlyAdded, uint256 userCached ); event DistributeReward( address indexed user, uint256 amount, uint256 userCached, uint256 userExcluded ); event CompoundReward( address indexed user, uint256 amountETH, uint256 amountTokenOut, uint256 userCached, uint256 userExcluded ); event DepositRewards( address indexed user, uint256 amount, uint256 latestTotalPerShare, bool areNew ); event PayBackLastClaim( address indexed user, uint256 amountPaidBack, uint256 userCached, uint256 userExcluded ); constructor(uint256 _firstClaim, uint256 _minLockup) { CREATED = block.timestamp; TOKEN = _msgSender(); FIRST_CLAIM_DELAY = _firstClaim; MIN_LOCKUP_TIME = _minLockup; } function update( address _wallet, uint256 _updateAmount, bool _removing ) external { require(_msgSender() == TOKEN, 'T'); if (_removing) { _removeShares(_wallet, _updateAmount); emit RemoveShares( _wallet, _updateAmount, rewards[_wallet].cached, rewards[_wallet].excluded ); } else { _addShares(_wallet, _updateAmount); emit AddShares( _wallet, _updateAmount, rewards[_wallet].cached, rewards[_wallet].excluded ); } } function depositRewards() external payable { _depositRewards(_msgSender(), msg.value, true); } function claim(bool _compound, uint256 _cmpndMinOut) external { require(block.timestamp >= CREATED + FIRST_CLAIM_DELAY, 'I'); _distributeReward(_msgSender(), false, _compound, _cmpndMinOut); } function paybackLastClaim() external payable { address _wallet = _msgSender(); require(!_isUnlocked(_wallet), 'ULK'); require(msg.value == lastClaimAmt[_wallet], 'E'); uint256 _userShares = shares[_wallet]; if (totalShares > _userShares) { // distribute to other reward-eligible users _removeShares(_wallet, _userShares); _depositRewards(_wallet, msg.value, true); _addShares(_wallet, _userShares); } else { _depositRewards(_wallet, msg.value, true); lastClaimAmt[_wallet] = 0; lastClaimTime[_wallet] = 0; } emit PayBackLastClaim( _wallet, msg.value, rewards[_wallet].cached, rewards[_wallet].excluded ); } function _addShares(address _wallet, uint256 _amount) internal { if (shares[_wallet] > 0) { _distributeReward(_wallet, true, false, 0); } uint256 sharesBefore = shares[_wallet]; totalShares += _amount; shares[_wallet] += _amount; if (sharesBefore == 0 && shares[_wallet] > 0) { totalUsers++; } rewards[_wallet].excluded = _cumulative(shares[_wallet]); } function _removeShares(address _wallet, uint256 _amount) internal { require(_amount <= shares[_wallet], 'R'); if (shares[_wallet] == 0) { return; } uint256 _unclaimed = _unclaimedRewards(_wallet); if (_unclaimed > 0) { uint256 _userShares = shares[_wallet]; if (totalShares > _userShares) { // distribute to other reward-eligible users totalShares -= _userShares; _depositRewards(_wallet, _unclaimed, false); totalShares += _userShares; rewards[_wallet].cached = 0; } else { _distributeReward(_wallet, false, false, 0); } } totalShares -= _amount; shares[_wallet] -= _amount; if (shares[_wallet] == 0) { totalUsers--; } lastClaimAmt[_wallet] = 0; lastClaimTime[_wallet] = 0; rewards[_wallet].excluded = _cumulative(shares[_wallet]); } function _depositRewards( address _wallet, uint256 _amount, bool _additive ) internal { require(_amount > 0 && totalShares > 0, 'D0'); totalDepositedGross += _amount; if (_additive) { totalDepositedNet += _amount; } _totalPerShare += (P * _amount) / totalShares; emit DepositRewards(_wallet, _amount, _totalPerShare, _additive); } function _distributeReward( address _wallet, bool _cache, bool _compound, uint256 _cmpndMinOut ) internal { if (shares[_wallet] == 0) { return; } bool _unlocked = _isUnlocked(_wallet); uint256 _amount = _unclaimedRewards(_wallet); rewards[_wallet].excluded = _cumulative(shares[_wallet]); if (_cache) { uint256 _newRewards = _amount - rewards[_wallet].cached; if (_newRewards == 0) { return; } rewards[_wallet].cached += _newRewards; emit CacheReward(_wallet, _newRewards, rewards[_wallet].cached); } else if (_compound) { require(_amount > 0, 'CA'); rewards[_wallet].cached = 0; lastClaimAmt[_wallet] = _unlocked ? _amount : lastClaimAmt[_wallet] + _amount; lastClaimTime[_wallet] = block.timestamp; rewards[_wallet].realized += _amount; totalDistributed += _amount; uint256 _amountOut = ILPAdapter(TOKEN).swapETHForToken{ value: _amount }( TOKEN, _cmpndMinOut, _wallet ); emit CompoundReward( _wallet, _amount, _amountOut, rewards[_wallet].cached, rewards[_wallet].excluded ); } else { require(_unlocked, 'LK'); rewards[_wallet].cached = 0; if (_amount > 0) { lastClaimAmt[_wallet] = _amount; lastClaimTime[_wallet] = block.timestamp; rewards[_wallet].realized += _amount; totalDistributed += _amount; uint256 _bef = address(this).balance; (bool _s, ) = payable(_wallet).call{ value: _amount }(''); require(_s, 'D1'); require(address(this).balance >= _bef - _amount, 'D2'); emit DistributeReward( _wallet, _amount, rewards[_wallet].cached, rewards[_wallet].excluded ); } } } function _isUnlocked(address _wallet) internal view returns (bool) { bool _enoughUnclaimed = _unclaimedRewards(_wallet) >= lastClaimAmt[_wallet]; bool _minTimePassed = block.timestamp > lastClaimTime[_wallet] + MIN_LOCKUP_TIME; return _enoughUnclaimed && _minTimePassed; } function isUnlocked(address _wallet) external view returns (bool) { return _isUnlocked(_wallet); } function _unclaimedRewards(address _wallet) internal view returns (uint256) { if (shares[_wallet] == 0) { return 0; } uint256 _earned = _cumulative(shares[_wallet]) + rewards[_wallet].cached; uint256 _excluded = rewards[_wallet].excluded; if (_earned <= _excluded) { return 0; } return _earned - _excluded; } function unclaimedRewards(address _wallet) external view returns (uint256) { return _unclaimedRewards(_wallet); } function _cumulative(uint256 _share) internal view returns (uint256) { return (_share * _totalPerShare) / P; } receive() external payable { _depositRewards(_msgSender(), msg.value, true); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; interface IBurnable { function burn(uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; interface ILPAdapter { function swapETHForToken( address token, uint256 amountOutMin, address recipient ) external payable returns (uint256 amountOut); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; interface INonfungiblePositionManager is IERC721Metadata, IERC721Enumerable { struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } function positions( uint256 tokenId ) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool); function mint( MintParams calldata params ) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); function increaseLiquidity( IncreaseLiquidityParams calldata params ) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1); function decreaseLiquidity( DecreaseLiquidityParams calldata params ) external payable returns (uint256 amount0, uint256 amount1); function collect( CollectParams calldata params ) external payable returns (uint256 amount0, uint256 amount1); function transferFrom(address from, address to, uint256 tokenId) external; function refundETH() external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.24; interface IUniswapV3Pool { function tickSpacing() external view returns (int24); function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.24; interface IV3SwapRouter { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } function exactInputSingle( ExactInputSingleParams calldata params ) external payable returns (uint256 amountOut); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import '@openzeppelin/contracts/interfaces/IERC20.sol'; interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 wad) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({ token0: tokenA, token1: tokenB, fee: fee }); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress( address factory, PoolKey memory key ) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint160( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ) ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts/utils/Context.sol'; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol'; import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol'; import './interfaces/IBurnable.sol'; import './interfaces/ILPAdapter.sol'; import './interfaces/INonfungiblePositionManager.sol'; import './interfaces/IUniswapV3Pool.sol'; import './interfaces/IV3SwapRouter.sol'; import './interfaces/IWETH.sol'; contract LPAdapter is ILPAdapter, Context, Ownable { using SafeERC20 for IERC20; uint256 public lastCollect; uint256 public lastRebalance; uint256 public lpPositionId; address immutable ADMIN; uint256 immutable LP_COLLECT_FREQ; uint256 immutable LP_REBALANCE_FREQ; uint8 immutable LP_REBALANCE_PERC; IWETH immutable WETH; INonfungiblePositionManager immutable LP_MANAGER; IUniswapV3Factory immutable V3_FACTORY; IV3SwapRouter immutable ROUTER; uint256 _launchedAt; address _token0; address _token1; address _liquidityPool; uint24 _fee; constructor( address _admin, address _weth, address _lpManager, address _v3Factory, address _swapRouter, uint256 _collectFrequency, uint256 _lpRebalFreq, uint8 _lpRebalPerc ) Ownable(_msgSender()) { ADMIN = _admin; WETH = IWETH(_weth); LP_MANAGER = INonfungiblePositionManager(_lpManager); V3_FACTORY = IUniswapV3Factory(_v3Factory); ROUTER = IV3SwapRouter(_swapRouter); LP_COLLECT_FREQ = _collectFrequency; LP_REBALANCE_FREQ = _lpRebalFreq; LP_REBALANCE_PERC = _lpRebalPerc; lastCollect = block.timestamp; lastRebalance = block.timestamp; } function setLpId(uint256 _tokenId) external onlyOwner { require(lpPositionId == 0, 'F'); _launchedAt = block.timestamp; lpPositionId = _tokenId; (, , address _t0, address _t1, uint24 _f, , , , , , , ) = LP_MANAGER .positions(lpPositionId); _token0 = _t0; _token1 = _t1; _fee = _f; _liquidityPool = V3_FACTORY.getPool(_token0, _token1, _fee); LP_MANAGER.transferFrom(_msgSender(), address(this), _tokenId); } function removePositionAfterInactivity() external { // can only ever withdraw after 30 days of no fee collection activity // this would only happen if the token died which is pretty much // impossible because mullets are about to rule the fucking world require(block.timestamp > lastCollect + 30 days, 'I'); uint256 _tokenId = lpPositionId; lpPositionId = 0; LP_MANAGER.transferFrom(address(this), ADMIN, _tokenId); } function swapETHForToken( address _token, uint256 _amountOutMin, address _recipient ) external payable override returns (uint256 _amountOut) { require(msg.value > 0, 'E'); WETH.deposit{ value: msg.value }(); _amountOut = _swap( address(WETH), _token, msg.value, _amountOutMin, _recipient ); } function donateLiquidity( address _token, uint256 _amountTokens, uint256 _amountTokensMin, uint256 _amountWethMin ) external payable { require(lpPositionId > 0, 'ILP'); require(_token == _token0 || _token == _token1, 'P'); require(msg.value > 0 && _amountTokens > 0, 'DA'); uint256 _balBeforeTokens = IERC20(_token).balanceOf(address(this)); uint256 _balBeforeETH = address(this).balance - msg.value; uint256 _balBeforeWETH = WETH.balanceOf(address(this)); WETH.deposit{ value: msg.value }(); IERC20(_token).safeTransferFrom(_msgSender(), address(this), _amountTokens); uint256 _amountAdd0 = _token0 == _token ? _amountTokens : msg.value; uint256 _amountAdd1 = _token0 == _token ? msg.value : _amountTokens; uint256 _amount0Min = _token0 == _token ? _amountTokensMin : _amountWethMin; uint256 _amount1Min = _token0 == _token ? _amountWethMin : _amountTokensMin; IERC20(_token0).safeIncreaseAllowance(address(LP_MANAGER), _amountAdd0); IERC20(_token1).safeIncreaseAllowance(address(LP_MANAGER), _amountAdd1); LP_MANAGER.increaseLiquidity( INonfungiblePositionManager.IncreaseLiquidityParams({ tokenId: lpPositionId, amount0Desired: _amountAdd0, amount1Desired: _amountAdd1, amount0Min: _amount0Min, amount1Min: _amount1Min, deadline: block.timestamp }) ); TransferHelper.safeApprove(_token0, address(LP_MANAGER), 0); TransferHelper.safeApprove(_token1, address(LP_MANAGER), 0); uint256 _balFinalTokens = IERC20(_token).balanceOf(address(this)); if (_balFinalTokens > _balBeforeTokens) { IERC20(_token).safeTransfer( _msgSender(), _balFinalTokens - _balBeforeTokens ); } uint256 _balFinalWETH = WETH.balanceOf(address(this)); if (_balFinalWETH > _balBeforeWETH) { WETH.withdraw(_balFinalWETH - _balBeforeWETH); (bool _s, ) = payable(_msgSender()).call{ value: _balFinalWETH - _balBeforeWETH }(''); require(_s, 'SE'); require(address(this).balance >= _balBeforeETH, 'VE'); } } function _checkAndProcessLPFees() internal { if (lpPositionId == 0) { return; } if (block.timestamp < lastCollect + LP_COLLECT_FREQ) { return; } (, , , , , , bool _unlocked) = IUniswapV3Pool(_liquidityPool).slot0(); if (!_unlocked) { return; } (uint256 _amount0, uint256 _amount1) = _collect(); if (_amount0 == 0 && _amount1 == 0) { return; } address _token = _token0 == address(WETH) ? _token1 : _token0; uint256 _amountToken = _token0 == address(WETH) ? _amount1 : _amount0; if (_amountToken > 0) { _swap(_token, address(WETH), _amountToken, 0, address(this)); } uint256 _wethBal = WETH.balanceOf(address(this)); if (_wethBal > 0) { WETH.withdraw(_wethBal); } uint256 _adminETH = address(this).balance / 10; // 10% if (_adminETH > 0) { (bool _s, ) = payable(ADMIN).call{ value: _adminETH }(''); require(_s); } } function _checkAndRebalanceLp() internal { if (lpPositionId == 0) { return; } if (block.timestamp < lastRebalance + LP_REBALANCE_FREQ) { return; } if (lastRebalance > lastCollect || block.timestamp == lastCollect) { return; } (, , , , , , bool _unlocked) = IUniswapV3Pool(_liquidityPool).slot0(); if (!_unlocked) { return; } _withdrawBuyAndBurnFromLpPosition(); } function _collect() internal returns (uint256 _amount0, uint256 _amount1) { lastCollect = block.timestamp; (_amount0, _amount1) = LP_MANAGER.collect( INonfungiblePositionManager.CollectParams({ tokenId: lpPositionId, recipient: address(this), amount0Max: type(uint128).max, amount1Max: type(uint128).max }) ); } function _withdrawBuyAndBurnFromLpPosition() internal { lastRebalance = block.timestamp; (, , , , , , , uint128 _liquidity, , , , ) = LP_MANAGER.positions( lpPositionId ); LP_MANAGER.decreaseLiquidity( INonfungiblePositionManager.DecreaseLiquidityParams({ tokenId: lpPositionId, liquidity: (_liquidity * LP_REBALANCE_PERC) / 100, amount0Min: 0, amount1Min: 0, deadline: block.timestamp }) ); (uint256 _amount0, uint256 _amount1) = _collect(); address _token = _token0 == address(WETH) ? _token1 : _token0; uint256 _amountWETH = _token0 == address(WETH) ? _amount0 : _amount1; if (_amountWETH > 0) { _swap(address(WETH), _token, _amountWETH, 0, address(this)); } uint256 _tokensToBurn = IERC20(_token).balanceOf(address(this)); if (_tokensToBurn > 0) { IBurnable(_token).burn(_tokensToBurn); } } function _swap( address _tokenIn, address _tokenOut, uint256 _amountIn, uint256 _amountOutMin, address _recipient ) internal returns (uint256 _amountOut) { IERC20(_tokenIn).safeIncreaseAllowance(address(ROUTER), _amountIn); _amountOut = ROUTER.exactInputSingle( IV3SwapRouter.ExactInputSingleParams({ tokenIn: _tokenIn, tokenOut: _tokenOut, fee: _fee, recipient: _recipient, amountIn: _amountIn, amountOutMinimum: _amountOutMin, sqrtPriceLimitX96: 0 }) ); } receive() external payable {} }
{ "metadata": { "bytecodeHash": "none" }, "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_lpManager","type":"address"},{"internalType":"address","name":"_v3Factory","type":"address"},{"internalType":"address","name":"_swapRouter","type":"address"},{"internalType":"address","name":"_layerZeroEndpoint","type":"address"},{"internalType":"address","name":"_oftAdm","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":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","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":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ERC2612ExpiredSignature","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC2612InvalidSigner","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidDelegate","type":"error"},{"inputs":[],"name":"InvalidEndpointCall","type":"error"},{"inputs":[],"name":"InvalidLocalDecimals","type":"error"},{"inputs":[{"internalType":"bytes","name":"options","type":"bytes"}],"name":"InvalidOptions","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"LzTokenUnavailable","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"NoPeer","type":"error"},{"inputs":[{"internalType":"uint256","name":"msgValue","type":"uint256"}],"name":"NotEnoughNative","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"OnlyEndpoint","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"OnlyPeer","type":"error"},{"inputs":[],"name":"OnlySelf","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"name":"SimulationResult","type":"error"},{"inputs":[{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"}],"name":"SlippageExceeded","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","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":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"},{"internalType":"bytes","name":"options","type":"bytes"}],"indexed":false,"internalType":"struct EnforcedOptionParam[]","name":"_enforcedOptions","type":"tuple[]"}],"name":"EnforcedOptionSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"inspector","type":"address"}],"name":"MsgInspectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"guid","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"srcEid","type":"uint32"},{"indexed":true,"internalType":"address","name":"toAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"name":"OFTReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"guid","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":true,"internalType":"address","name":"fromAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountSentLD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"name":"OFTSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"eid","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"peer","type":"bytes32"}],"name":"PeerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"preCrimeAddress","type":"address"}],"name":"PreCrimeSet","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"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GAME_THEORY_REWARDS","outputs":[{"internalType":"contract GameTheoryRewards","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SEND","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SEND_AND_CALL","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"origin","type":"tuple"}],"name":"allowInitializePath","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[],"name":"approvalRequired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","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":"uint256","name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"uint16","name":"_msgType","type":"uint16"},{"internalType":"bytes","name":"_extraOptions","type":"bytes"}],"name":"combineOptions","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimalConversionRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amountTokens","type":"uint256"},{"internalType":"uint256","name":"_amountTokensMin","type":"uint256"},{"internalType":"uint256","name":"_amountWethMin","type":"uint256"}],"name":"donateLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpointV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"}],"name":"enforcedOptions","outputs":[{"internalType":"bytes","name":"enforcedOption","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"","type":"tuple"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"address","name":"_sender","type":"address"}],"name":"isComposeMsgSender","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"bytes32","name":"_peer","type":"bytes32"}],"name":"isPeer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastCollect","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastRebalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpPositionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"origin","type":"tuple"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"executor","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct InboundPacket[]","name":"_packets","type":"tuple[]"}],"name":"lzReceiveAndRevert","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"lzReceiveSimulate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"msgInspector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"nextNonce","outputs":[{"internalType":"uint64","name":"nonce","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oApp","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oAppVersion","outputs":[{"internalType":"uint64","name":"senderVersion","type":"uint64"},{"internalType":"uint64","name":"receiverVersion","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"oftVersion","outputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"},{"internalType":"uint64","name":"version","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"peers","outputs":[{"internalType":"bytes32","name":"peer","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"preCrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"bytes","name":"extraOptions","type":"bytes"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"oftCmd","type":"bytes"}],"internalType":"struct SendParam","name":"_sendParam","type":"tuple"}],"name":"quoteOFT","outputs":[{"components":[{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"uint256","name":"maxAmountLD","type":"uint256"}],"internalType":"struct OFTLimit","name":"oftLimit","type":"tuple"},{"components":[{"internalType":"int256","name":"feeAmountLD","type":"int256"},{"internalType":"string","name":"description","type":"string"}],"internalType":"struct OFTFeeDetail[]","name":"oftFeeDetails","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"amountSentLD","type":"uint256"},{"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"internalType":"struct OFTReceipt","name":"oftReceipt","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"bytes","name":"extraOptions","type":"bytes"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"oftCmd","type":"bytes"}],"internalType":"struct SendParam","name":"_sendParam","type":"tuple"},{"internalType":"bool","name":"_payInLzToken","type":"bool"}],"name":"quoteSend","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"msgFee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removePositionAfterInactivity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"bytes","name":"extraOptions","type":"bytes"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"oftCmd","type":"bytes"}],"internalType":"struct SendParam","name":"_sendParam","type":"tuple"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"_fee","type":"tuple"},{"internalType":"address","name":"_refundAddress","type":"address"}],"name":"send","outputs":[{"components":[{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"internalType":"struct MessagingReceipt","name":"msgReceipt","type":"tuple"},{"components":[{"internalType":"uint256","name":"amountSentLD","type":"uint256"},{"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"internalType":"struct OFTReceipt","name":"oftReceipt","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegate","type":"address"}],"name":"setDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"},{"internalType":"bytes","name":"options","type":"bytes"}],"internalType":"struct EnforcedOptionParam[]","name":"_enforcedOptions","type":"tuple[]"}],"name":"setEnforcedOptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"setLpId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_msgInspector","type":"address"}],"name":"setMsgInspector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"bytes32","name":"_peer","type":"bytes32"}],"name":"setPeer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_preCrime","type":"address"}],"name":"setPreCrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sharedDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amountOutMin","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"swapETHForToken","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"payable","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"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6102c06040523480156200001257600080fd5b5060405162008ed838038062008ed883398101604081905262000035916200182d565b8086868686610e106201518060036040518060400160405280600e81526020016d141c9bda9958dd08135d5b1b195d60921b81525080604051806040016040528060018152602001603160f81b8152506040518060400160405280600e81526020016d141c9bda9958dd08135d5b1b195d60921b8152506040518060400160405280600681526020016513555313115560d21b8152508e8e8383620000df6200051f60201b60201c565b84848181818133806200010d57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620001188162000524565b506001600160a01b0380831660805281166200014757604051632d618d8160e21b815260040160405180910390fd5b60805160405163ca5eb5e160e01b81526001600160a01b0383811660048301529091169063ca5eb5e190602401600060405180830381600087803b1580156200018f57600080fd5b505af1158015620001a4573d6000803e3d6000fd5b5050505050505050620001bc6200057460201b60201c565b60ff168360ff161015620001e3576040516301e9714b60e41b815260040160405180910390fd5b620001f0600684620018d7565b620001fd90600a620019f0565b60a0525060089150620002139050838262001a9f565b50600962000222828262001a9f565b506200023a9550879450600a93505062000579915050565b610160526200024b81600b62000579565b61018052815160208084019190912061012052815190820120610140524660e052620002db6101205161014051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60c05250503061010052506001600160a01b039788166101a052958716610220529386166102405291851661026052909316610280526101c0929092526101e09190915260ff166102005242600d819055600e5560405162015180906203f480906200034790620017f7565b9182526020820152604001604051809103906000f0801580156200036f573d6000803e3d6000fd5b506001600160a01b03166102a05230600081815260146020819052604082208054600160ff1991821681179092557f4f26c3876aa9f4b92579780beea1161a61f87ebf1ec6ee865b299e447ecba99c805482168317905561dead84527f8b9e18c5e04efe171d1e4f682ad90d753958a5ffe56db5290b0236c8e0b6db0080549091168217905592909190620004099088908b6064620005b2565b6001600160a01b0316815260208101919091526040016000908120805460ff1916921515929092179091556001906014906200044a87308b6101f4620005b2565b6001600160a01b0316815260208101919091526040016000908120805460ff1916921515929092179091556001906014906200048b87308b610bb8620005b2565b6001600160a01b0316815260208101919091526040016000908120805460ff191692151592909217909155600190601490620004cc87308b612710620005b2565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905562000513620005003390565b6b033b2e3c9fd0803ce800000062000624565b50505050505062001f07565b601290565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600690565b60006020835110156200059957620005918362000662565b9050620005ac565b81620005a6848262001a9f565b5060ff90505b92915050565b6000806000846001600160a01b0316866001600160a01b031610620005d9578486620005dc565b85855b604080516060810182526001600160a01b0380851682528316602082015262ffffff8816918101919091529193509150620006188882620006a5565b98975050505050505050565b6001600160a01b038216620006505760405163ec442f0560e01b81526000600482015260240162000104565b6200065e60008383620007a2565b5050565b600080829050601f8151111562000690578260405163305a27a960e01b815260040162000104919062001b91565b80516200069d8262001bc6565b179392505050565b600081602001516001600160a01b031682600001516001600160a01b031610620006ce57600080fd5b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201207fff0000000000000000000000000000000000000000000000000000000000000060a08401529085901b6001600160601b03191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b620007ac62000890565b620007b662000b55565b471562000817576102a0516001600160a01b031663152111f7476040518263ffffffff1660e01b81526004016000604051808303818588803b158015620007fc57600080fd5b505af115801562000811573d6000803e3d6000fd5b50505050505b600062000825848362000c2a565b905080156200085a5762000844846101a0518362000ca060201b60201c565b6200085a846101a0518362000dd360201b60201c565b6200087284846200086c848662001beb565b62000ca0565b6200088a848462000884848662001beb565b62000dd3565b50505050565b600f546000036200089d57565b6101c051600d54620008b0919062001c01565b421015620008ba57565b60135460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa15801562000905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200092b919062001c4e565b9650505050505050806200093c5750565b6000806200094962000f9c565b915091508160001480156200095c575080155b156200096757505050565b610220516011546000916001600160a01b0391821691161462000996576011546001600160a01b0316620009a3565b6012546001600160a01b03165b610220516011549192506000916001600160a01b03908116911614620009ca5783620009cc565b825b90508015620009f057620009ee8261022051836000306200106660201b60201c565b505b610220516040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801562000a3b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000a61919062001cec565b9050801562000acc5761022051604051632e1a7d4d60e01b8152600481018390526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b15801562000ab257600080fd5b505af115801562000ac7573d6000803e3d6000fd5b505050505b600062000adb600a4762001d1c565b9050801562000b4c5760006101a0516001600160a01b03168260405160006040518083038185875af1925050503d806000811462000b36576040519150601f19603f3d011682016040523d82523d6000602084013e62000b3b565b606091505b505090508062000b4a57600080fd5b505b50505050505050565b600f5460000362000b6257565b6101e051600e5462000b75919062001c01565b42101562000b7f57565b600d54600e54118062000b935750600d5442145b1562000b9b57565b60135460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa15801562000be6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c0c919062001c4e565b96505050505050508062000c1d5750565b62000c2762001183565b50565b600080600f5411801562000c3e5750600082115b801562000c5857506013546001600160a01b038481169116145b801562000c74575060b460105462000c71919062001c01565b42105b15620005ac5762000c8760058362001d1c565b9050801562000c97578062000c99565b815b9392505050565b6001600160a01b03831662000ccf57806007600082825462000cc3919062001c01565b9091555062000d439050565b6001600160a01b0383166000908152600560205260409020548181101562000d245760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640162000104565b6001600160a01b03841660009081526005602052604090209082900390555b6001600160a01b03821662000d615760078054829003905562000d80565b6001600160a01b03821660009081526005602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405162000dc691815260200190565b60405180910390a3505050565b6001600160a01b03831660009081526014602052604090205460ff1662000f0a576102a0516040516315dfa99560e11b81526001600160a01b03858116600483015290911690632bbf532a90602401602060405180830381865afa15801562000e40573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e66919062001d33565b62000e995760405162461bcd60e51b81526020600482015260026024820152614c4b60f01b604482015260640162000104565b6102a0516040516315dd37b360e01b81526001600160a01b0385811660048301526024820184905260016044830152909116906315dd37b390606401600060405180830381600087803b15801562000ef057600080fd5b505af115801562000f05573d6000803e3d6000fd5b505050505b6001600160a01b03821660009081526014602052604090205460ff1662000f97576102a0516040516315dd37b360e01b81526001600160a01b0384811660048301526024820184905260006044830152909116906315dd37b390606401600060405180830381600087803b15801562000f8257600080fd5b505af115801562000b4c573d6000803e3d6000fd5b505050565b42600d556102405160408051608081018252600f54815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b039081166024850152915181166044840152925190921660648201526000928392169063fc6f78659060840160408051808303816000875af115801562001037573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200105d919062001d51565b90939092509050565b6102805160009062001084906001600160a01b038816908662001483565b610280516040805160e0810182526001600160a01b03898116825288811660208301908152601354600160a01b900462ffffff90811684860190815288841660608601908152608086018c815260a087018c8152600060c0890190815298516304e45aaf60e01b8152975187166004890152945186166024880152915190921660448601529051831660648501525160848401525160a48301529151821660c48201529116906304e45aaf9060e4016020604051808303816000875af115801562001153573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001179919062001cec565b9695505050505050565b42600e5561024051600f5460405163133f757160e31b815260048101919091526000916001600160a01b0316906399fbab889060240161018060405180830381865afa158015620011d8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620011fe919062001da2565b50505050975050505050505050610240516001600160a01b0316630c49ccbe6040518060a00160405280600f54815260200160646102005160ff168662001246919062001e92565b62001252919062001ec0565b6001600160801b031681526020016000815260200160008152602001428152506040518263ffffffff1660e01b8152600401620012c89190815181526020808301516001600160801b03169082015260408083015190820152606080830151908201526080918201519181019190915260a00190565b60408051808303816000875af1158015620012e7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200130d919062001d51565b5060009050806200131d62000f9c565b610220516011549294509092506000916001600160a01b0390811691161462001352576011546001600160a01b03166200135f565b6012546001600160a01b03165b610220516011549192506000916001600160a01b0390811691161462001386578262001388565b835b90508015620013a75761022051620013a590838360003062001066565b505b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015620013ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001415919062001cec565b905080156200147b57604051630852cd8d60e31b8152600481018290526001600160a01b038416906342966c6890602401600060405180830381600087803b1580156200146157600080fd5b505af115801562001476573d6000803e3d6000fd5b505050505b505050505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015620014d4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620014fa919062001cec565b90506200088a84846200150e858562001c01565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620015689085908390620015d416565b6200088a57604080516001600160a01b038516602482015260006044808301919091528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620015c89186916200168516565b6200088a848262001685565b6000806000846001600160a01b031684604051620015f3919062001ee9565b6000604051808303816000865af19150503d806000811462001632576040519150601f19603f3d011682016040523d82523d6000602084013e62001637565b606091505b5091509150818015620016655750805115806200166557508080602001905181019062001665919062001d33565b80156200167c57506000856001600160a01b03163b115b95945050505050565b60006200169c6001600160a01b03841683620016ef565b90508051600014158015620016c4575080806020019051810190620016c2919062001d33565b155b1562000f9757604051635274afe760e01b81526001600160a01b038416600482015260240162000104565b606062000c998383600084600080856001600160a01b0316848660405162001718919062001ee9565b60006040518083038185875af1925050503d806000811462001757576040519150601f19603f3d011682016040523d82523d6000602084013e6200175c565b606091505b5090925090506200117986838360608262001782576200177c82620017cd565b62000c99565b81511580156200179a57506001600160a01b0384163b155b15620017c557604051639996b31560e01b81526001600160a01b038516600482015260240162000104565b508062000c99565b805115620017de5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6113c88062007b1083390190565b6001600160a01b038116811462000c2757600080fd5b8051620018288162001805565b919050565b60008060008060008060c087890312156200184757600080fd5b8651620018548162001805565b6020880151909650620018678162001805565b60408801519095506200187a8162001805565b60608801519094506200188d8162001805565b6080880151909350620018a08162001805565b60a0880151909250620018b38162001805565b809150509295509295509295565b634e487b7160e01b600052601160045260246000fd5b60ff8281168282160390811115620005ac57620005ac620018c1565b600181815b8085111562001934578160001904821115620019185762001918620018c1565b808516156200192657918102915b93841c9390800290620018f8565b509250929050565b6000826200194d57506001620005ac565b816200195c57506000620005ac565b81600181146200197557600281146200198057620019a0565b6001915050620005ac565b60ff841115620019945762001994620018c1565b50506001821b620005ac565b5060208310610133831016604e8410600b8410161715620019c5575081810a620005ac565b620019d18383620018f3565b8060001904821115620019e857620019e8620018c1565b029392505050565b600062000c9960ff8416836200193c565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168062001a2c57607f821691505b60208210810362001a4d57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562000f97576000816000526020600020601f850160051c8101602086101562001a7e5750805b601f850160051c820191505b818110156200147b5782815560010162001a8a565b81516001600160401b0381111562001abb5762001abb62001a01565b62001ad38162001acc845462001a17565b8462001a53565b602080601f83116001811462001b0b576000841562001af25750858301515b600019600386901b1c1916600185901b1785556200147b565b600085815260208120601f198616915b8281101562001b3c5788860151825594840194600190910190840162001b1b565b508582101562001b5b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60005b8381101562001b8857818101518382015260200162001b6e565b50506000910152565b602081526000825180602084015262001bb281604085016020870162001b6b565b601f01601f19169190910160400192915050565b8051602080830151919081101562001a4d5760001960209190910360031b1b16919050565b81810381811115620005ac57620005ac620018c1565b80820180821115620005ac57620005ac620018c1565b8051600281900b81146200182857600080fd5b805161ffff811681146200182857600080fd5b805180151581146200182857600080fd5b600080600080600080600060e0888a03121562001c6a57600080fd5b875162001c778162001805565b965062001c876020890162001c17565b955062001c976040890162001c2a565b945062001ca76060890162001c2a565b935062001cb76080890162001c2a565b925060a088015160ff8116811462001cce57600080fd5b915062001cde60c0890162001c3d565b905092959891949750929550565b60006020828403121562001cff57600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b60008262001d2e5762001d2e62001d06565b500490565b60006020828403121562001d4657600080fd5b62000c998262001c3d565b6000806040838503121562001d6557600080fd5b505080516020909101519092909150565b805162ffffff811681146200182857600080fd5b80516001600160801b03811681146200182857600080fd5b6000806000806000806000806000806000806101808d8f03121562001dc657600080fd5b8c516001600160601b038116811462001dde57600080fd5b9b5062001dee60208e016200181b565b9a5062001dfe60408e016200181b565b995062001e0e60608e016200181b565b985062001e1e60808e0162001d76565b975062001e2e60a08e0162001c17565b965062001e3e60c08e0162001c17565b955062001e4e60e08e0162001d8a565b94506101008d015193506101208d0151925062001e6f6101408e0162001d8a565b915062001e806101608e0162001d8a565b90509295989b509295989b509295989b565b6001600160801b0381811683821602808216919082811462001eb85762001eb8620018c1565b505092915050565b60006001600160801b038381168062001edd5762001edd62001d06565b92169190910492915050565b6000825162001efd81846020870162001b6b565b9190910192915050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a051615a16620020fa600039600081816108050152818161319301528181613db701528181613e800152613f2a015260008181612b7a0152612c4001526000610e7b015260008181610d7f01528181610f15015281816114b2015281816114e90152818161157e015281816116000152818161163801528181611e05015281816140e1015281816141790152614201015260008181611317015281816113860152818161170a0152818161179101528181611966015281816119dd01528181613894015281816138ee015281816139350152818161397701528181613a0801528181614352015281816143ac01526143f20152600061424501526000613b10015260006137b2015260008181611dd6015281816132200152818161324b0152613a8601526000612b4301526000612b1601526000612618015260006125f00152600061254b015260006125750152600061259f01526000818161087f01528181613047015281816130bc015261329f01526000818161067101528181610c3901528181611f870152818161230d015281816127a301528181612e3b0152818161350801526135c10152615a166000f3fe60806040526004361061036f5760003560e01c80637ecebe00116101c6578063bb0b6a53116100f7578063d146bff411610095578063dd62ed3e1161006f578063dd62ed3e14610a34578063f2fde38b14610a7a578063fc0c546a146105f5578063ff7bd03d14610a9a57600080fd5b8063d146bff4146109de578063d4243885146109f4578063d505accf14610a1457600080fd5b8063c1236b6d116100d1578063c1236b6d14610975578063c7c7f5b31461098a578063ca5eb5e1146109ab578063d045a0dc146109cb57600080fd5b8063bb0b6a5314610915578063bc70b35414610942578063bd815db01461096257600080fd5b8063903e10ba116101645780639f68b9641161013e5780639f68b964146108a1578063a9059cbb146108b5578063b731ea0a146108d5578063b98bd070146108f557600080fd5b8063903e10ba1461084557806395d89b4114610858578063963efcaa1461086d57600080fd5b806384b0196e116101a057806384b0196e146107b7578063857749b0146107df5780638bab0885146107f35780638da5cb5b1461082757600080fd5b80637ecebe001461076457806382413eac1461078457806383231895146107a457600080fd5b80633400288b116102a05780635e280f111161023e57806370a082311161021857806370a08231146106c9578063715018a6146106ff5780637284e416146107145780637d25a05e1461072957600080fd5b80635e280f111461065f5780636e6d8e0c146106935780636fc1b31e146106a957600080fd5b806342966c681161027a57806342966c68146105d557806352ae2879146105f55780635535d461146106085780635a0dfe4d1461062857600080fd5b80633400288b146105735780633644e515146105935780633b6f743b146105a857600080fd5b8063156a0d0f1161030d5780631f5e1334116102e75780631f5e1334146104fc57806323b872dd146105115780632e455f3714610531578063313ce5671461055157600080fd5b8063156a0d0f1461049e57806317442b70146104c557806318160ddd146104e757600080fd5b8063106b9ca111610349578063106b9ca114610405578063111ecdad1461042957806313137d6514610461578063134d4f251461047657600080fd5b806306fdde031461037b578063095ea7b3146103a65780630d35b415146103d657600080fd5b3661037657005b600080fd5b34801561038757600080fd5b50610390610aba565b60405161039d91906146c5565b60405180910390f35b3480156103b257600080fd5b506103c66103c13660046146ed565b610b4c565b604051901515815260200161039d565b3480156103e257600080fd5b506103f66103f136600461472b565b610b66565b60405161039d9392919061475f565b34801561041157600080fd5b5061041b600e5481565b60405190815260200161039d565b34801561043557600080fd5b50600454610449906001600160a01b031681565b6040516001600160a01b03909116815260200161039d565b61047461046f366004614852565b610c37565b005b34801561048257600080fd5b5061048b600281565b60405161ffff909116815260200161039d565b3480156104aa57600080fd5b506040805162b9270b60e21b8152600160208201520161039d565b3480156104d157600080fd5b506040805160018152600260208201520161039d565b3480156104f357600080fd5b5060075461041b565b34801561050857600080fd5b5061048b600181565b34801561051d57600080fd5b506103c661052c3660046148f1565b610cf7565b34801561053d57600080fd5b5061047461054c366004614932565b610d1d565b34801561055d57600080fd5b5060125b60405160ff909116815260200161039d565b34801561057f57600080fd5b5061047461058e366004614964565b610fa7565b34801561059f57600080fd5b5061041b610fbd565b3480156105b457600080fd5b506105c86105c336600461498e565b610fcc565b60405161039d91906149df565b3480156105e157600080fd5b506104746105f0366004614932565b611033565b34801561060157600080fd5b5030610449565b34801561061457600080fd5b50610390610623366004614a06565b611040565b34801561063457600080fd5b506103c6610643366004614964565b63ffffffff919091166000908152600160205260409020541490565b34801561066b57600080fd5b506104497f000000000000000000000000000000000000000000000000000000000000000081565b34801561069f57600080fd5b5061041b600d5481565b3480156106b557600080fd5b506104746106c4366004614a32565b6110e5565b3480156106d557600080fd5b5061041b6106e4366004614a32565b6001600160a01b031660009081526005602052604090205490565b34801561070b57600080fd5b50610474611142565b34801561072057600080fd5b50610390611156565b34801561073557600080fd5b5061074c610744366004614964565b600092915050565b6040516001600160401b03909116815260200161039d565b34801561077057600080fd5b5061041b61077f366004614a32565b611176565b34801561079057600080fd5b506103c661079f366004614a4f565b611194565b6104746107b2366004614ab5565b6111a9565b3480156107c357600080fd5b506107cc6118e9565b60405161039d9796959493929190614af0565b3480156107eb57600080fd5b506006610561565b3480156107ff57600080fd5b506104497f000000000000000000000000000000000000000000000000000000000000000081565b34801561083357600080fd5b506000546001600160a01b0316610449565b61041b610853366004614b89565b61192f565b34801561086457600080fd5b50610390611a05565b34801561087957600080fd5b5061041b7f000000000000000000000000000000000000000000000000000000000000000081565b3480156108ad57600080fd5b5060006103c6565b3480156108c157600080fd5b506103c66108d03660046146ed565b611a14565b3480156108e157600080fd5b50600254610449906001600160a01b031681565b34801561090157600080fd5b50610474610910366004614c0f565b611a22565b34801561092157600080fd5b5061041b610930366004614c50565b60016020526000908152604090205481565b34801561094e57600080fd5b5061039061095d366004614c6b565b611a3c565b610474610970366004614c0f565b611be4565b34801561098157600080fd5b50610474611d6e565b61099d610998366004614ccd565b611e65565b60405161039d929190614d2f565b3480156109b757600080fd5b506104746109c6366004614a32565b611f60565b6104746109d9366004614852565b611fb6565b3480156109ea57600080fd5b5061041b600f5481565b348015610a0057600080fd5b50610474610a0f366004614a32565b611fe5565b348015610a2057600080fd5b50610474610a2f366004614d90565b61203b565b348015610a4057600080fd5b5061041b610a4f366004614e01565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205490565b348015610a8657600080fd5b50610474610a95366004614a32565b612175565b348015610aa657600080fd5b506103c6610ab5366004614e2f565b6121b0565b606060088054610ac990614e4b565b80601f0160208091040260200160405190810160405280929190818152602001828054610af590614e4b565b8015610b425780601f10610b1757610100808354040283529160200191610b42565b820191906000526020600020905b815481529060010190602001808311610b2557829003601f168201915b5050505050905090565b600033610b5a8185856121e6565b60019150505b92915050565b60408051808201909152600080825260208201526060610b99604051806040016040528060008152602001600081525090565b60408051808201825260008082526001600160401b03602080840182905284518381529081019094529195509182610bf4565b604080518082019091526000815260606020820152815260200190600190039081610bcc5790505b509350600080610c19604089013560608a0135610c1460208c018c614c50565b6121f8565b60408051808201909152918252602082015296989597505050505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163314610c87576040516391ac5e4f60e01b81523360048201526024015b60405180910390fd5b60208701803590610ca190610c9c908a614c50565b61223c565b14610cdf57610cb36020880188614c50565b60405163309afaf360e21b815263ffffffff909116600482015260208801356024820152604401610c7e565b610cee87878787878787612278565b50505050505050565b600033610d058582856123df565b610d1085858561245d565b60019150505b9392505050565b610d256124bc565b600f5415610d595760405162461bcd60e51b81526020600482015260016024820152602360f91b6044820152606401610c7e565b42601055600f81905560405163133f757160e31b815260048101829052600090819081907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906399fbab889060240161018060405180830381865afa158015610dcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df39190614edc565b5050601180546001600160a01b03808b166001600160a01b0319928316811790935560128054828c169316831790556013805462ffffff808c16600160a01b90810262ffffff60a01b199093169290921792839055604051630b4c774160e11b81526004810196909652602486019490945290049091166044830152989d50969b50949950507f00000000000000000000000000000000000000000000000000000000000000009095169650631698ee8295505060649092019250610eb6915050565b602060405180830381865afa158015610ed3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef79190614fbd565b601380546001600160a01b0319166001600160a01b039283161790557f0000000000000000000000000000000000000000000000000000000000000000166323b872dd336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015230602482015260448101879052606401600060405180830381600087803b158015610f8957600080fd5b505af1158015610f9d573d6000803e3d6000fd5b5050505050505050565b610faf6124bc565b610fb982826124e9565b5050565b6000610fc761253e565b905090565b60408051808201909152600080825260208201526000610ffc60408501356060860135610c146020880188614c50565b91505060008061100c8684612669565b90925090506110296110216020880188614c50565b83838861278d565b9695505050505050565b61103d338261286e565b50565b60036020908152600092835260408084209091529082529020805461106490614e4b565b80601f016020809104026020016040519081016040528092919081815260200182805461109090614e4b565b80156110dd5780601f106110b2576101008083540402835291602001916110dd565b820191906000526020600020905b8154815290600101906020018083116110c057829003601f168201915b505050505081565b6110ed6124bc565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527ff0be4f1e87349231d80c36b33f9e8639658eeaf474014dee15a3e6a4d4414197906020015b60405180910390a150565b61114a6124bc565b61115460006128a4565b565b60606040518060600160405280602881526020016159e260289139905090565b6001600160a01b0381166000908152600c6020526040812054610b60565b6001600160a01b03811630145b949350505050565b6000600f54116111e15760405162461bcd60e51b81526020600482015260036024820152620494c560ec1b6044820152606401610c7e565b6011546001600160a01b038581169116148061120a57506012546001600160a01b038581169116145b61123a5760405162461bcd60e51b81526020600482015260016024820152600560fc1b6044820152606401610c7e565b60003411801561124a5750600083115b61127b5760405162461bcd60e51b8152602060048201526002602482015261444160f01b6044820152606401610c7e565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa1580156112c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e69190614fda565b905060006112f43447615009565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801561135e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113829190614fda565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156113df57600080fd5b505af11580156113f3573d6000803e3d6000fd5b50505050506114146114023390565b6001600160a01b0389169030896128f4565b6011546000906001600160a01b038981169116146114325734611434565b865b6011549091506000906001600160a01b038a81169116146114555787611457565b345b6011549091506000906001600160a01b038b8116911614611478578661147a565b875b6011549091506000906001600160a01b038c811691161461149b578861149d565b875b6011549091506114d7906001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000008661295b565b60125461150e906001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000008561295b565b6040805160c081018252600f5481526020810186815281830186815260608301868152608084018681524260a08601908152955163219f5d1760e01b8152945160048601529251602485015290516044840152516064830152516084820152905160a48201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063219f5d179060c4016060604051808303816000875af11580156115c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115eb919061501c565b505060115461162691506001600160a01b03167f000000000000000000000000000000000000000000000000000000000000000060006129e5565b60125461165e906001600160a01b03167f000000000000000000000000000000000000000000000000000000000000000060006129e5565b6040516370a0823160e01b81523060048201526000906001600160a01b038d16906370a0823190602401602060405180830381865afa1580156116a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c99190614fda565b9050878111156116f2576116f2336116e18a84615009565b6001600160a01b038f169190612ade565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611759573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177d9190614fda565b9050868111156118da576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016632e1a7d4d6117c08984615009565b6040518263ffffffff1660e01b81526004016117de91815260200190565b600060405180830381600087803b1580156117f857600080fd5b505af115801561180c573d6000803e3d6000fd5b5050505060006118193390565b6001600160a01b031661182c8984615009565b604051600081818185875af1925050503d8060008114611868576040519150601f19603f3d011682016040523d82523d6000602084013e61186d565b606091505b50509050806118a35760405162461bcd60e51b8152602060048201526002602482015261534560f01b6044820152606401610c7e565b884710156118d85760405162461bcd60e51b8152602060048201526002602482015261564560f01b6044820152606401610c7e565b505b50505050505050505050505050565b6000606080600080600060606118fd612b0f565b611905612b3c565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b60008034116119645760405162461bcd60e51b81526020600482015260016024820152604560f81b6044820152606401610c7e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156119bf57600080fd5b505af11580156119d3573d6000803e3d6000fd5b50505050506111a17f000000000000000000000000000000000000000000000000000000000000000085348686612b69565b606060098054610ac990614e4b565b600033610b5a81858561245d565b611a2a6124bc565b610fb9611a3782846150f2565b612caf565b63ffffffff8416600090815260036020908152604080832061ffff87168452909152812080546060929190611a7090614e4b565b80601f0160208091040260200160405190810160405280929190818152602001828054611a9c90614e4b565b8015611ae95780601f10611abe57610100808354040283529160200191611ae9565b820191906000526020600020905b815481529060010190602001808311611acc57829003601f168201915b505050505090508051600003611b395783838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509294506111a19350505050565b6000839003611b495790506111a1565b60028310611bc757611b9084848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612db692505050565b80611b9e8460028188615209565b604051602001611bb093929190615233565b6040516020818303038152906040529150506111a1565b8383604051639a6d49cd60e01b8152600401610c7e929190615284565b60005b81811015611ced5736838383818110611c0257611c02615298565b9050602002810190611c1491906152ae565b9050611c47611c266020830183614c50565b602083013563ffffffff919091166000908152600160205260409020541490565b611c515750611ce5565b3063d045a0dc60c08301358360a0810135611c706101008301836152cf565b611c81610100890160e08a01614a32565b611c8f6101208a018a6152cf565b6040518963ffffffff1660e01b8152600401611cb1979695949392919061532a565b6000604051808303818588803b158015611cca57600080fd5b505af1158015611cde573d6000803e3d6000fd5b5050505050505b600101611be7565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611d2c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d5491908101906153b0565b604051638351eea760e01b8152600401610c7e91906146c5565b600d54611d7e9062278d0061541d565b4211611db05760405162461bcd60e51b81526020600482015260016024820152604960f81b6044820152606401610c7e565b600f805460009091556040516323b872dd60e01b81523060048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166024830152604482018390527f000000000000000000000000000000000000000000000000000000000000000016906323b872dd906064015b600060405180830381600087803b158015611e4a57600080fd5b505af1158015611e5e573d6000803e3d6000fd5b5050505050565b611e6d61462e565b6040805180820190915260008082526020820152600080611ea433604089013560608a0135611e9f60208c018c614c50565b612de2565b91509150600080611eb58984612669565b9092509050611ee1611eca60208b018b614c50565b8383611edb368d90038d018d615430565b8b612e08565b60408051808201909152858152602080820186905282519298509096503391907f85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a90611f2f908d018d614c50565b6040805163ffffffff909216825260208201899052810187905260600160405180910390a350505050935093915050565b611f686124bc565b60405163ca5eb5e160e01b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063ca5eb5e190602401611e30565b333014611fd65760405163029a949d60e31b815260040160405180910390fd5b610cee87878787878787610cdf565b611fed6124bc565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c242776090602001611137565b8342111561205f5760405163313c898160e11b815260048101859052602401610c7e565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886120ac8c6001600160a01b03166000908152600c6020526040902080546001810190915590565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050600061210782612f13565b9050600061211782878787612f40565b9050896001600160a01b0316816001600160a01b03161461215e576040516325c0072360e11b81526001600160a01b0380831660048301528b166024820152604401610c7e565b6121698a8a8a6121e6565b50505050505050505050565b61217d6124bc565b6001600160a01b0381166121a757604051631e4fbdf760e01b815260006004820152602401610c7e565b61103d816128a4565b60006020820180359060019083906121c89086614c50565b63ffffffff1681526020810191909152604001600020541492915050565b6121f38383836001612f6e565b505050565b60008061220485613043565b915081905083811015612234576040516371c4efed60e01b81526004810182905260248101859052604401610c7e565b935093915050565b63ffffffff811660009081526001602052604081205480610b605760405163f6ff4fb760e01b815263ffffffff84166004820152602401610c7e565b600061228a612287878761307a565b90565b905060006122b6826122a461229f8a8a613092565b6130b5565b6122b160208d018d614c50565b6130ea565b9050602886111561237d5760006122f36122d660608c0160408d01615462565b6122e360208d018d614c50565b846122ee8c8c6130fe565b613149565b604051633e5ac80960e11b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637cb59012906123499086908d90600090879060040161547f565b600060405180830381600087803b15801561236357600080fd5b505af1158015612377573d6000803e3d6000fd5b50505050505b6001600160a01b038216887fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c6123b660208d018d614c50565b6040805163ffffffff9092168252602082018690520160405180910390a3505050505050505050565b6001600160a01b038381166000908152600660209081526040808320938616835292905220546000198114612457578181101561244857604051637dc7a0d960e11b81526001600160a01b03841660048201526024810182905260448101839052606401610c7e565b61245784848484036000612f6e565b50505050565b6001600160a01b03831661248757604051634b637e8f60e11b815260006004820152602401610c7e565b6001600160a01b0382166124b15760405163ec442f0560e01b815260006004820152602401610c7e565b6121f383838361317b565b6000546001600160a01b031633146111545760405163118cdaa760e01b8152336004820152602401610c7e565b63ffffffff8216600081815260016020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b910160405180910390a15050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561259757507f000000000000000000000000000000000000000000000000000000000000000046145b156125c157507f000000000000000000000000000000000000000000000000000000000000000090565b610fc7604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60608060006126c6856020013561267f86613298565b61268c60a08901896152cf565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506132c492505050565b90935090506000816126d95760016126dc565b60025b90506126fc6126ee6020880188614c50565b8261095d60808a018a6152cf565b6004549093506001600160a01b031615612784576004805460405163043a78eb60e01b81526001600160a01b039091169163043a78eb916127419188918891016154b0565b602060405180830381865afa15801561275e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278291906154d5565b505b50509250929050565b60408051808201909152600080825260208201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ddc28c586040518060a001604052808863ffffffff1681526020016127f08961223c565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b81526004016128259291906154f2565b6040805180830381865afa158015612841573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612865919061559b565b95945050505050565b6001600160a01b03821661289857604051634b637e8f60e11b815260006004820152602401610c7e565b610fb98260008361317b565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b0384811660248301528381166044830152606482018390526124579186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061333e565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156129ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129cf9190614fda565b905061245784846129e0858561541d565b6133a1565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691612a4191906155b7565b6000604051808303816000865af19150503d8060008114612a7e576040519150601f19603f3d011682016040523d82523d6000602084013e612a83565b606091505b5091509150818015612aad575080511580612aad575080806020019051810190612aad91906154d5565b611e5e5760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401610c7e565b6040516001600160a01b038381166024830152604482018390526121f391859182169063a9059cbb90606401612929565b6060610fc77f0000000000000000000000000000000000000000000000000000000000000000600a613431565b6060610fc77f0000000000000000000000000000000000000000000000000000000000000000600b613431565b6000612b9f6001600160a01b0387167f00000000000000000000000000000000000000000000000000000000000000008661295b565b6040805160e0810182526001600160a01b03888116825287811660208301908152601354600160a01b900462ffffff90811684860190815287841660608601908152608086018b815260a087018b8152600060c0890190815298516304e45aaf60e01b8152975187166004890152945186166024880152915190921660448601529051831660648501525160848401525160a48301529151821660c48201527f0000000000000000000000000000000000000000000000000000000000000000909116906304e45aaf9060e4016020604051808303816000875af1158015612c8b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110299190614fda565b60005b8151811015612d8657612ce1828281518110612cd057612cd0615298565b602002602001015160400151612db6565b818181518110612cf357612cf3615298565b60200260200101516040015160036000848481518110612d1557612d15615298565b60200260200101516000015163ffffffff1663ffffffff1681526020019081526020016000206000848481518110612d4f57612d4f615298565b60200260200101516020015161ffff1661ffff1681526020019081526020016000209081612d7d9190615611565b50600101612cb2565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b6748160405161113791906156d0565b600281015161ffff8116600314610fb95781604051639a6d49cd60e01b8152600401610c7e91906146c5565b600080612df08585856121f8565b9092509050612dff868361286e565b94509492505050565b612e1061462e565b6000612e1f84600001516134dc565b602085015190915015612e3957612e398460200151613504565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632637a450826040518060a001604052808b63ffffffff168152602001612e898c61223c565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b8152600401612ec59291906154f2565b60806040518083038185885af1158015612ee3573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612f08919061575b565b979650505050505050565b6000610b60612f2061253e565b8360405161190160f01b8152600281019290925260228201526042902090565b600080600080612f52888888886135e6565b925092509250612f6282826136b5565b50909695505050505050565b6001600160a01b038416612f985760405163e602df0560e01b815260006004820152602401610c7e565b6001600160a01b038316612fc257604051634a1406b160e11b815260006004820152602401610c7e565b6001600160a01b038085166000908152600660209081526040808320938716835292905220829055801561245757826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161303591815260200190565b60405180910390a350505050565b60007f000000000000000000000000000000000000000000000000000000000000000061307081846157bb565b610b6091906157cf565b60006130896020828486615209565b610d16916157e6565b60006130a2602860208486615209565b6130ab91615804565b60c01c9392505050565b6000610b607f00000000000000000000000000000000000000000000000000000000000000006001600160401b0384166157cf565b60006130f6848461376e565b509092915050565b606061310d8260288186615209565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929695505050505050565b6060848484846040516020016131629493929190615834565b6040516020818303038152906040529050949350505050565b6131836137a4565b61318b613b02565b4715613206577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663152111f7476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156131ec57600080fd5b505af1158015613200573d6000803e3d6000fd5b50505050505b60006132128483613be5565b9050801561327057613245847f000000000000000000000000000000000000000000000000000000000000000083613c4e565b613270847f000000000000000000000000000000000000000000000000000000000000000083613d78565b613284848461327f8486615009565b613c4e565b61245784846132938486615009565b613d78565b6000610b607f0000000000000000000000000000000000000000000000000000000000000000836157bb565b805160609015158061330d5784846040516020016132f992919091825260c01b6001600160c01b031916602082015260280190565b604051602081830303815290604052613334565b848433856040516020016133249493929190615883565b6040516020818303038152906040525b9150935093915050565b60006133536001600160a01b03841683613f82565b9050805160001415801561337857508080602001905181019061337691906154d5565b155b156121f357604051635274afe760e01b81526001600160a01b0384166004820152602401610c7e565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526133f28482613f90565b612457576040516001600160a01b0384811660248301526000604483015261342791869182169063095ea7b390606401612929565b612457848261333e565b606060ff831461344b5761344483614033565b9050610b60565b81805461345790614e4b565b80601f016020809104026020016040519081016040528092919081815260200182805461348390614e4b565b80156134d05780601f106134a5576101008083540402835291602001916134d0565b820191906000526020600020905b8154815290600101906020018083116134b357829003601f168201915b50505050509050610b60565b6000813414613500576040516304fb820960e51b8152346004820152602401610c7e565b5090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e4fe1d946040518163ffffffff1660e01b8152600401602060405180830381865afa158015613564573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135889190614fbd565b90506001600160a01b0381166135b1576040516329b99a9560e11b815260040160405180910390fd5b610fb96001600160a01b038216337f0000000000000000000000000000000000000000000000000000000000000000856128f4565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561362157506000915060039050826136ab565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015613675573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166136a1575060009250600191508290506136ab565b9250600091508190505b9450945094915050565b60008260038111156136c9576136c96158c6565b036136d2575050565b60018260038111156136e6576136e66158c6565b036137045760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115613718576137186158c6565b036137395760405163fce698f760e01b815260048101829052602401610c7e565b600382600381111561374d5761374d6158c6565b03610fb9576040516335e2f38360e21b815260048101829052602401610c7e565b6001600160a01b0382166137985760405163ec442f0560e01b815260006004820152602401610c7e565b610fb96000838361317b565b600f546000036137b057565b7f0000000000000000000000000000000000000000000000000000000000000000600d546137de919061541d565b4210156137e757565b60135460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa158015613831573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385591906158dc565b9650505050505050806138655750565b600080613870614072565b91509150816000148015613882575080155b1561388c57505050565b6011546000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b039081169116146138d6576011546001600160a01b03166138e3565b6012546001600160a01b03165b6011549091506000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b039081169116146139255783613927565b825b9050801561395f5761395d827f000000000000000000000000000000000000000000000000000000000000000083600030612b69565b505b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156139c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ea9190614fda565b90508015613a6d57604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015613a5457600080fd5b505af1158015613a68573d6000803e3d6000fd5b505050505b6000613a7a600a476157bb565b90508015610cee5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168260405160006040518083038185875af1925050503d8060008114613aef576040519150601f19603f3d011682016040523d82523d6000602084013e613af4565b606091505b5050905080610f9d57600080fd5b600f54600003613b0e57565b7f0000000000000000000000000000000000000000000000000000000000000000600e54613b3c919061541d565b421015613b4557565b600d54600e541180613b585750600d5442145b15613b5f57565b60135460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa158015613ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bcd91906158dc565b965050505050505080613bdd5750565b61103d614158565b600080600f54118015613bf85750600082115b8015613c1157506013546001600160a01b038481169116145b8015613c2a575060b4601054613c27919061541d565b42105b15610b6057613c3a6005836157bb565b90508015613c485780610d16565b50919050565b6001600160a01b038316613c79578060076000828254613c6e919061541d565b90915550613ceb9050565b6001600160a01b03831660009081526005602052604090205481811015613ccc5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610c7e565b6001600160a01b03841660009081526005602052604090209082900390555b6001600160a01b038216613d0757600780548290039055613d26565b6001600160a01b03821660009081526005602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051613d6b91815260200190565b60405180910390a3505050565b6001600160a01b03831660009081526014602052604090205460ff16613edd576040516315dfa99560e11b81526001600160a01b0384811660048301527f00000000000000000000000000000000000000000000000000000000000000001690632bbf532a90602401602060405180830381865afa158015613dfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e2291906154d5565b613e535760405162461bcd60e51b81526020600482015260026024820152614c4b60f01b6044820152606401610c7e565b6040516315dd37b360e01b81526001600160a01b03848116600483015260248201839052600160448301527f000000000000000000000000000000000000000000000000000000000000000016906315dd37b390606401600060405180830381600087803b158015613ec457600080fd5b505af1158015613ed8573d6000803e3d6000fd5b505050505b6001600160a01b03821660009081526014602052604090205460ff166121f3576040516315dd37b360e01b81526001600160a01b03838116600483015260248201839052600060448301527f000000000000000000000000000000000000000000000000000000000000000016906315dd37b390606401600060405180830381600087803b158015613f6e57600080fd5b505af1158015610cee573d6000803e3d6000fd5b6060610d16838360006144ee565b6000806000846001600160a01b031684604051613fad91906155b7565b6000604051808303816000865af19150503d8060008114613fea576040519150601f19603f3d011682016040523d82523d6000602084013e613fef565b606091505b509150915081801561401957508051158061401957508080602001905181019061401991906154d5565b80156128655750505050506001600160a01b03163b151590565b6060600061404083614581565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b42600d5560408051608081018252600f54815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b0390811660248501529151811660448401529251909216606482015260009182917f00000000000000000000000000000000000000000000000000000000000000009091169063fc6f78659060840160408051808303816000875af115801561412b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061414f9190615974565b90939092509050565b42600e55600f5460405163133f757160e31b81526000916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916399fbab88916141b09160040190815260200190565b61018060405180830381865afa1580156141ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141f29190614edc565b505050509750505050505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630c49ccbe6040518060a00160405280600f54815260200160647f000000000000000000000000000000000000000000000000000000000000000060ff16866142729190615998565b61427c91906159bb565b6001600160801b031681526020016000815260200160008152602001428152506040518263ffffffff1660e01b81526004016142f69190600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b60408051808303816000875af1158015614314573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143389190615974565b5050600080614345614072565b60115491935091506000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03908116911614614394576011546001600160a01b03166143a1565b6012546001600160a01b03165b6011549091506000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b039081169116146143e357826143e5565b835b9050801561441d5761441b7f00000000000000000000000000000000000000000000000000000000000000008383600030612b69565b505b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015614464573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144889190614fda565b905080156144e657604051630852cd8d60e31b8152600481018290526001600160a01b038416906342966c6890602401600060405180830381600087803b1580156144d257600080fd5b505af1158015612169573d6000803e3d6000fd5b505050505050565b6060814710156145135760405163cd78605960e01b8152306004820152602401610c7e565b600080856001600160a01b0316848660405161452f91906155b7565b60006040518083038185875af1925050503d806000811461456c576040519150601f19603f3d011682016040523d82523d6000602084013e614571565b606091505b50915091506110298683836145a9565b600060ff8216601f811115610b6057604051632cd44ac360e21b815260040160405180910390fd5b6060826145be576145b982614605565b610d16565b81511580156145d557506001600160a01b0384163b155b156145fe57604051639996b31560e01b81526001600160a01b0385166004820152602401610c7e565b5080610d16565b8051156146155780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60405180606001604052806000801916815260200160006001600160401b03168152602001614670604051806040016040528060008152602001600081525090565b905290565b60005b83811015614690578181015183820152602001614678565b50506000910152565b600081518084526146b1816020860160208601614675565b601f01601f19169290920160200192915050565b602081526000610d166020830184614699565b6001600160a01b038116811461103d57600080fd5b6000806040838503121561470057600080fd5b823561470b816146d8565b946020939093013593505050565b600060e08284031215613c4857600080fd5b60006020828403121561473d57600080fd5b81356001600160401b0381111561475357600080fd5b6111a184828501614719565b8351815260208085015190820152600060a08201604060a0604085015281865180845260c08601915060c08160051b8701019350602080890160005b838110156147da5788870360bf190185528151805188528301518388018790526147c787890182614699565b975050938201939082019060010161479b565b505087516060880152505050602085015160808501525090506111a1565b600060608284031215613c4857600080fd5b60008083601f84011261481c57600080fd5b5081356001600160401b0381111561483357600080fd5b60208301915083602082850101111561484b57600080fd5b9250929050565b600080600080600080600060e0888a03121561486d57600080fd5b61487789896147f8565b96506060880135955060808801356001600160401b038082111561489a57600080fd5b6148a68b838c0161480a565b909750955060a08a013591506148bb826146d8565b90935060c089013590808211156148d157600080fd5b506148de8a828b0161480a565b989b979a50959850939692959293505050565b60008060006060848603121561490657600080fd5b8335614911816146d8565b92506020840135614921816146d8565b929592945050506040919091013590565b60006020828403121561494457600080fd5b5035919050565b803563ffffffff8116811461495f57600080fd5b919050565b6000806040838503121561497757600080fd5b61470b8361494b565b801515811461103d57600080fd5b600080604083850312156149a157600080fd5b82356001600160401b038111156149b757600080fd5b6149c385828601614719565b92505060208301356149d481614980565b809150509250929050565b815181526020808301519082015260408101610b60565b61ffff8116811461103d57600080fd5b60008060408385031215614a1957600080fd5b614a228361494b565b915060208301356149d4816149f6565b600060208284031215614a4457600080fd5b8135610d16816146d8565b60008060008060a08587031215614a6557600080fd5b614a6f86866147f8565b935060608501356001600160401b03811115614a8a57600080fd5b614a968782880161480a565b9094509250506080850135614aaa816146d8565b939692955090935050565b60008060008060808587031215614acb57600080fd5b8435614ad6816146d8565b966020860135965060408601359560600135945092505050565b60ff60f81b881681526000602060e06020840152614b1160e084018a614699565b8381036040850152614b23818a614699565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015614b7757835183529284019291840191600101614b5b565b50909c9b505050505050505050505050565b600080600060608486031215614b9e57600080fd5b8335614ba9816146d8565b9250602084013591506040840135614bc0816146d8565b809150509250925092565b60008083601f840112614bdd57600080fd5b5081356001600160401b03811115614bf457600080fd5b6020830191508360208260051b850101111561484b57600080fd5b60008060208385031215614c2257600080fd5b82356001600160401b03811115614c3857600080fd5b614c4485828601614bcb565b90969095509350505050565b600060208284031215614c6257600080fd5b610d168261494b565b60008060008060608587031215614c8157600080fd5b614c8a8561494b565b93506020850135614c9a816149f6565b925060408501356001600160401b03811115614cb557600080fd5b614cc18782880161480a565b95989497509550505050565b60008060008385036080811215614ce357600080fd5b84356001600160401b03811115614cf957600080fd5b614d0587828801614719565b9450506040601f1982011215614d1a57600080fd5b506020840191506060840135614bc0816146d8565b600060c082019050835182526001600160401b0360208501511660208301526040840151614d6a604084018280518252602090810151910152565b5082516080830152602083015160a0830152610d16565b60ff8116811461103d57600080fd5b600080600080600080600060e0888a031215614dab57600080fd5b8735614db6816146d8565b96506020880135614dc6816146d8565b955060408801359450606088013593506080880135614de481614d81565b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215614e1457600080fd5b8235614e1f816146d8565b915060208301356149d4816146d8565b600060608284031215614e4157600080fd5b610d1683836147f8565b600181811c90821680614e5f57607f821691505b602082108103613c4857634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b805161495f816146d8565b805162ffffff8116811461495f57600080fd5b8051600281900b811461495f57600080fd5b80516001600160801b038116811461495f57600080fd5b6000806000806000806000806000806000806101808d8f031215614eff57600080fd5b8c516bffffffffffffffffffffffff81168114614f1b57600080fd5b9b50614f2960208e01614e95565b9a50614f3760408e01614e95565b9950614f4560608e01614e95565b9850614f5360808e01614ea0565b9750614f6160a08e01614eb3565b9650614f6f60c08e01614eb3565b9550614f7d60e08e01614ec5565b94506101008d015193506101208d01519250614f9c6101408e01614ec5565b9150614fab6101608e01614ec5565b90509295989b509295989b509295989b565b600060208284031215614fcf57600080fd5b8151610d16816146d8565b600060208284031215614fec57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610b6057610b60614ff3565b60008060006060848603121561503157600080fd5b61503a84614ec5565b925060208401519150604084015190509250925092565b604051606081016001600160401b038111828210171561507357615073614e7f565b60405290565b604080519081016001600160401b038111828210171561507357615073614e7f565b604051601f8201601f191681016001600160401b03811182821017156150c3576150c3614e7f565b604052919050565b60006001600160401b038211156150e4576150e4614e7f565b50601f01601f191660200190565b60006001600160401b038084111561510c5761510c614e7f565b8360051b602061511d81830161509b565b86815291850191818101903684111561513557600080fd5b865b848110156151fd5780358681111561514f5760008081fd5b880160603682900312156151635760008081fd5b61516b615051565b6151748261494b565b815285820135615183816149f6565b818701526040828101358981111561519b5760008081fd5b929092019136601f8401126151b05760008081fd5b82356151c36151be826150cb565b61509b565b81815236898387010111156151d85760008081fd5b818986018a830137600091810189019190915290820152845250918301918301615137565b50979650505050505050565b6000808585111561521957600080fd5b8386111561522657600080fd5b5050820193919092039150565b60008451615245818460208901614675565b8201838582376000930192835250909392505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6020815260006111a160208301848661525b565b634e487b7160e01b600052603260045260246000fd5b6000823561013e198336030181126152c557600080fd5b9190910192915050565b6000808335601e198436030181126152e657600080fd5b8301803591506001600160401b0382111561530057600080fd5b60200191503681900382131561484b57600080fd5b6001600160401b038116811461103d57600080fd5b63ffffffff6153388961494b565b168152602088013560208201526000604089013561535581615315565b6001600160401b03811660408401525087606083015260e0608083015261538060e08301878961525b565b6001600160a01b03861660a084015282810360c08401526153a281858761525b565b9a9950505050505050505050565b6000602082840312156153c257600080fd5b81516001600160401b038111156153d857600080fd5b8201601f810184136153e957600080fd5b80516153f76151be826150cb565b81815285602083850101111561540c57600080fd5b612865826020830160208601614675565b80820180821115610b6057610b60614ff3565b60006040828403121561544257600080fd5b61544a615079565b82358152602083013560208201528091505092915050565b60006020828403121561547457600080fd5b8135610d1681615315565b60018060a01b038516815283602082015261ffff831660408201526080606082015260006110296080830184614699565b6040815260006154c36040830185614699565b82810360208401526128658185614699565b6000602082840312156154e757600080fd5b8151610d1681614980565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a0608084015261552860e0840182614699565b90506060850151603f198483030160a08501526155458282614699565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b60006040828403121561557d57600080fd5b615585615079565b9050815181526020820151602082015292915050565b6000604082840312156155ad57600080fd5b610d16838361556b565b600082516152c5818460208701614675565b601f8211156121f3576000816000526020600020601f850160051c810160208610156155f25750805b601f850160051c820191505b818110156144e6578281556001016155fe565b81516001600160401b0381111561562a5761562a614e7f565b61563e816156388454614e4b565b846155c9565b602080601f831160018114615673576000841561565b5750858301515b600019600386901b1c1916600185901b1785556144e6565b600085815260208120601f198616915b828110156156a257888601518255948401946001909101908401615683565b50858210156156c05787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561574d57888303603f190185528151805163ffffffff1684528781015161ffff1688850152860151606087850181905261573981860183614699565b9689019694505050908601906001016156f9565b509098975050505050505050565b60006080828403121561576d57600080fd5b615775615051565b82518152602083015161578781615315565b6020820152615799846040850161556b565b60408201529392505050565b634e487b7160e01b600052601260045260246000fd5b6000826157ca576157ca6157a5565b500490565b8082028115828204841417610b6057610b60614ff3565b80356020831015610b6057600019602084900360031b1b1692915050565b6001600160c01b0319813581811691600885101561582c5780818660080360031b1b83161692505b505092915050565b6001600160401b0360c01b8560c01b16815263ffffffff60e01b8460e01b16600882015282600c8201526000825161587381602c850160208701614675565b91909101602c0195945050505050565b8481526001600160401b0360c01b8460c01b166020820152826028820152600082516158b6816048850160208701614675565b9190910160480195945050505050565b634e487b7160e01b600052602160045260246000fd5b600080600080600080600060e0888a0312156158f757600080fd5b8751615902816146d8565b965061591060208901614eb3565b95506040880151615920816149f6565b6060890151909550615931816149f6565b6080890151909450615942816149f6565b60a089015190935061595381614d81565b60c089015190925061596481614980565b8091505092959891949750929550565b6000806040838503121561598757600080fd5b505080516020909101519092909150565b6001600160801b0381811683821602808216919082811461582c5761582c614ff3565b60006001600160801b03808416806159d5576159d56157a5565b9216919091049291505056fe427573696e65737320696e207468652066726f6e742c20706172747920696e20746865206261636ba164736f6c6343000818000a61010060405234801561001157600080fd5b506040516113c83803806113c883398101604081905261003091610046565b426080523360a05260c09190915260e05261006a565b6000806040838503121561005957600080fd5b505080516020909101519092909150565b60805160a05160c05160e0516113026100c6600039600081816103f60152610b8a0152600081816103ac01526107e80152600081816102a80152818161052b0152610e9001526000818161025e015261080901526113026000f3fe6080604052600436106101185760003560e01c806382bfefc8116100a0578063ce7c2ac211610064578063ce7c2ac21461034d578063d505a3641461037a578063ea7af02d1461039a578063efca2eed146103ce578063feeabb14146103e457600080fd5b806382bfefc814610296578063949813b8146102e2578063a78d329e14610302578063b77cf9c61461030a578063bff1f9e11461033757600080fd5b80633a98ef39116100e75780633a98ef39146101e55780634011c039146102095780634223a1991461021f578063697e0ef21461024c5780636ac1966f1461028057600080fd5b80630700037d14610131578063152111f71461018d57806315dd37b3146101955780632bbf532a146101b557600080fd5b3661012c5761012a335b346001610418565b005b600080fd5b34801561013d57600080fd5b5061016d61014c36600461119f565b60056020526000908152604090208054600182015460029092015490919083565b604080519384526020840192909252908201526060015b60405180910390f35b61012a61051d565b3480156101a157600080fd5b5061012a6101b03660046111d1565b610528565b3480156101c157600080fd5b506101d56101d036600461119f565b610660565b6040519015158152602001610184565b3480156101f157600080fd5b506101fb60015481565b604051908152602001610184565b34801561021557600080fd5b506101fb60085481565b34801561022b57600080fd5b506101fb61023a36600461119f565b60036020526000908152604090205481565b34801561025857600080fd5b506101fb7f000000000000000000000000000000000000000000000000000000000000000081565b34801561028c57600080fd5b506101fb60095481565b3480156102a257600080fd5b506102ca7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610184565b3480156102ee57600080fd5b506101fb6102fd36600461119f565b610671565b61012a61067c565b34801561031657600080fd5b506101fb61032536600461119f565b60046020526000908152604090205481565b34801561034357600080fd5b506101fb60005481565b34801561035957600080fd5b506101fb61036836600461119f565b60026020526000908152604090205481565b34801561038657600080fd5b5061012a61039536600461120d565b6107e3565b3480156103a657600080fd5b506101fb7f000000000000000000000000000000000000000000000000000000000000000081565b3480156103da57600080fd5b506101fb60075481565b3480156103f057600080fd5b506101fb7f000000000000000000000000000000000000000000000000000000000000000081565b60008211801561042a57506000600154115b6104605760405162461bcd60e51b8152602060048201526002602482015261044360f41b60448201526064015b60405180910390fd5b8160086000828254610472919061124d565b9091555050801561049557816009600082825461048f919061124d565b90915550505b6001546104a683600160601b611260565b6104b09190611277565b600660008282546104c1919061124d565b9091555050600654604080518481526020810192909252821515908201526001600160a01b038416907fb1124c952fdad130b5fd37d89d424fc26de2c06e0a94bd75afc5d596939429d5906060015b60405180910390a2505050565b61052633610122565b565b337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316146105845760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610457565b80156105f5576105948383610871565b6001600160a01b0383166000818152600560209081526040918290208054600190910154835187815292830191909152918101919091527f540d84ae9bd4002d192eb164830a11352726e8a25a3bf8d3db5341be164ab43f90606001610510565b6105ff8383610a54565b6001600160a01b0383166000818152600560209081526040918290208054600190910154835187815292830191909152918101919091527f067751958776933403288298f84550d155f9dbcd6eb4730644700e6432cf593990606001610510565b600061066b82610b3f565b92915050565b600061066b82610bc5565b3361068681610b3f565b156106b95760405162461bcd60e51b8152602060048201526003602482015262554c4b60e81b6044820152606401610457565b6001600160a01b03811660009081526003602052604090205434146107045760405162461bcd60e51b81526020600482015260016024820152604560f81b6044820152606401610457565b6001600160a01b03811660009081526002602052604090205460015481101561074c576107318282610871565b61073d82346001610418565b6107478282610a54565b61077f565b61075882346001610418565b6001600160a01b038216600090815260036020908152604080832083905560049091528120555b6001600160a01b03821660008181526005602090815260409182902080546001909101548351348152928301919091528183015290517f3053ee017378450829686d3535b1a19372fb47be10b6019e0adf7d73802198419181900360600190a25050565b61082d7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000061124d565b4210156108605760405162461bcd60e51b81526020600482015260016024820152604960f81b6044820152606401610457565b61086d3360008484610c5d565b5050565b6001600160a01b0382166000908152600260205260409020548111156108bd5760405162461bcd60e51b81526020600482015260016024820152602960f91b6044820152606401610457565b6001600160a01b03821660009081526002602052604081205490036108e0575050565b60006108eb83610bc5565b9050801561097f576001600160a01b03831660009081526002602052604090205460015481101561096f5780600160008282546109289190611299565b9091555061093a905084836000610418565b806001600082825461094c919061124d565b90915550506001600160a01b03841660009081526005602052604081205561097d565b61097d846000806000610c5d565b505b81600160008282546109919190611299565b90915550506001600160a01b038316600090815260026020526040812080548492906109be908490611299565b90915550506001600160a01b03831660009081526002602052604081205490036109f7576000805490806109f1836112ac565b91905055505b6001600160a01b0383166000908152600360209081526040808320839055600482528083208390556002909152902054610a3090611164565b6001600160a01b039093166000908152600560205260409020600101929092555050565b6001600160a01b03821660009081526002602052604090205415610a8057610a80826001600080610c5d565b6001600160a01b0382166000908152600260205260408120546001805491928492610aac90849061124d565b90915550506001600160a01b03831660009081526002602052604081208054849290610ad990849061124d565b909155505080158015610b0357506001600160a01b03831660009081526002602052604090205415155b15610b1d57600080549080610b17836112c3565b91905055505b6001600160a01b038316600090815260026020526040902054610a3090611164565b6001600160a01b0381166000908152600360205260408120548190610b6384610bc5565b6001600160a01b0385166000908152600460205260408120549290911015925090610baf907f00000000000000000000000000000000000000000000000000000000000000009061124d565b42119050818015610bbd5750805b949350505050565b6001600160a01b0381166000908152600260205260408120548103610bec57506000919050565b6001600160a01b0382166000908152600560209081526040808320546002909252822054610c1990611164565b610c23919061124d565b6001600160a01b038416600090815260056020526040902060010154909150808211610c53575060009392505050565b610bbd8183611299565b6001600160a01b0384166000908152600260205260409020541561115e576000610c8685610b3f565b90506000610c9386610bc5565b6001600160a01b038716600090815260026020526040902054909150610cb890611164565b6001600160a01b0387166000908152600560205260409020600101558415610d94576001600160a01b038616600090815260056020526040812054610cfd9083611299565b905080600003610d0f5750505061115e565b6001600160a01b03871660009081526005602052604081208054839290610d3790849061124d565b90915550506001600160a01b038716600081815260056020908152604091829020548251858152918201527f9703c1b4b1ae4060b6a0f8f3c75c56c59b213baef5fc209cb0901bf4ae2d5b4f91015b60405180910390a25061115b565b8315610f815760008111610dcf5760405162461bcd60e51b8152602060048201526002602482015261434160f01b6044820152606401610457565b6001600160a01b03861660009081526005602052604081205581610e16576001600160a01b038616600090815260036020526040902054610e1190829061124d565b610e18565b805b6001600160a01b03871660009081526003602090815260408083209390935560048152828220429055600590529081206002018054839290610e5b90849061124d565b925050819055508060076000828254610e74919061124d565b909155505060405163481f085d60e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830181905260248301869052908816604483015260009163903e10ba90849060640160206040518083038185885af1158015610ef3573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f1891906112dc565b6001600160a01b03881660008181526005602090815260409182902080546001909101548351888152928301869052928201526060810191909152919250907f8ec1ee04b6af38951c1cea10602bc0e8cc5ea264f74ccafecb0edc76f18d2fef90608001610d86565b81610fb35760405162461bcd60e51b81526020600482015260026024820152614c4b60f01b6044820152606401610457565b6001600160a01b038616600090815260056020526040812055801561115b576001600160a01b03861660009081526003602090815260408083208490556004825280832042905560059091528120600201805483929061101490849061124d565b92505081905550806007600082825461102d919061124d565b909155505060405147906000906001600160a01b0389169084908381818185875af1925050503d806000811461107f576040519150601f19603f3d011682016040523d82523d6000602084013e611084565b606091505b50509050806110ba5760405162461bcd60e51b8152602060048201526002602482015261443160f01b6044820152606401610457565b6110c48383611299565b4710156110f85760405162461bcd60e51b8152602060048201526002602482015261221960f11b6044820152606401610457565b6001600160a01b03881660008181526005602090815260409182902080546001909101548351888152928301919091528183015290517f891de4aee0b667a0bddf1d07a815a893c17366a034433e6760b9fc4cb2a40b789181900360600190a250505b50505b50505050565b6000600160601b600654836111799190611260565b61066b9190611277565b80356001600160a01b038116811461119a57600080fd5b919050565b6000602082840312156111b157600080fd5b6111ba82611183565b9392505050565b8035801515811461119a57600080fd5b6000806000606084860312156111e657600080fd5b6111ef84611183565b925060208401359150611204604085016111c1565b90509250925092565b6000806040838503121561122057600080fd5b611229836111c1565b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561066b5761066b611237565b808202811582820484141761066b5761066b611237565b60008261129457634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561066b5761066b611237565b6000816112bb576112bb611237565b506000190190565b6000600182016112d5576112d5611237565b5060010190565b6000602082840312156112ee57600080fd5b505191905056fea164736f6c6343000818000a000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe880000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98400000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc450000000000000000000000001a44076050125825900e736c501f859c50fe728c0000000000000000000000005cc3488c10e76a837feae51f94fdd50acfe57c4b
Deployed Bytecode
0x60806040526004361061036f5760003560e01c80637ecebe00116101c6578063bb0b6a53116100f7578063d146bff411610095578063dd62ed3e1161006f578063dd62ed3e14610a34578063f2fde38b14610a7a578063fc0c546a146105f5578063ff7bd03d14610a9a57600080fd5b8063d146bff4146109de578063d4243885146109f4578063d505accf14610a1457600080fd5b8063c1236b6d116100d1578063c1236b6d14610975578063c7c7f5b31461098a578063ca5eb5e1146109ab578063d045a0dc146109cb57600080fd5b8063bb0b6a5314610915578063bc70b35414610942578063bd815db01461096257600080fd5b8063903e10ba116101645780639f68b9641161013e5780639f68b964146108a1578063a9059cbb146108b5578063b731ea0a146108d5578063b98bd070146108f557600080fd5b8063903e10ba1461084557806395d89b4114610858578063963efcaa1461086d57600080fd5b806384b0196e116101a057806384b0196e146107b7578063857749b0146107df5780638bab0885146107f35780638da5cb5b1461082757600080fd5b80637ecebe001461076457806382413eac1461078457806383231895146107a457600080fd5b80633400288b116102a05780635e280f111161023e57806370a082311161021857806370a08231146106c9578063715018a6146106ff5780637284e416146107145780637d25a05e1461072957600080fd5b80635e280f111461065f5780636e6d8e0c146106935780636fc1b31e146106a957600080fd5b806342966c681161027a57806342966c68146105d557806352ae2879146105f55780635535d461146106085780635a0dfe4d1461062857600080fd5b80633400288b146105735780633644e515146105935780633b6f743b146105a857600080fd5b8063156a0d0f1161030d5780631f5e1334116102e75780631f5e1334146104fc57806323b872dd146105115780632e455f3714610531578063313ce5671461055157600080fd5b8063156a0d0f1461049e57806317442b70146104c557806318160ddd146104e757600080fd5b8063106b9ca111610349578063106b9ca114610405578063111ecdad1461042957806313137d6514610461578063134d4f251461047657600080fd5b806306fdde031461037b578063095ea7b3146103a65780630d35b415146103d657600080fd5b3661037657005b600080fd5b34801561038757600080fd5b50610390610aba565b60405161039d91906146c5565b60405180910390f35b3480156103b257600080fd5b506103c66103c13660046146ed565b610b4c565b604051901515815260200161039d565b3480156103e257600080fd5b506103f66103f136600461472b565b610b66565b60405161039d9392919061475f565b34801561041157600080fd5b5061041b600e5481565b60405190815260200161039d565b34801561043557600080fd5b50600454610449906001600160a01b031681565b6040516001600160a01b03909116815260200161039d565b61047461046f366004614852565b610c37565b005b34801561048257600080fd5b5061048b600281565b60405161ffff909116815260200161039d565b3480156104aa57600080fd5b506040805162b9270b60e21b8152600160208201520161039d565b3480156104d157600080fd5b506040805160018152600260208201520161039d565b3480156104f357600080fd5b5060075461041b565b34801561050857600080fd5b5061048b600181565b34801561051d57600080fd5b506103c661052c3660046148f1565b610cf7565b34801561053d57600080fd5b5061047461054c366004614932565b610d1d565b34801561055d57600080fd5b5060125b60405160ff909116815260200161039d565b34801561057f57600080fd5b5061047461058e366004614964565b610fa7565b34801561059f57600080fd5b5061041b610fbd565b3480156105b457600080fd5b506105c86105c336600461498e565b610fcc565b60405161039d91906149df565b3480156105e157600080fd5b506104746105f0366004614932565b611033565b34801561060157600080fd5b5030610449565b34801561061457600080fd5b50610390610623366004614a06565b611040565b34801561063457600080fd5b506103c6610643366004614964565b63ffffffff919091166000908152600160205260409020541490565b34801561066b57600080fd5b506104497f0000000000000000000000001a44076050125825900e736c501f859c50fe728c81565b34801561069f57600080fd5b5061041b600d5481565b3480156106b557600080fd5b506104746106c4366004614a32565b6110e5565b3480156106d557600080fd5b5061041b6106e4366004614a32565b6001600160a01b031660009081526005602052604090205490565b34801561070b57600080fd5b50610474611142565b34801561072057600080fd5b50610390611156565b34801561073557600080fd5b5061074c610744366004614964565b600092915050565b6040516001600160401b03909116815260200161039d565b34801561077057600080fd5b5061041b61077f366004614a32565b611176565b34801561079057600080fd5b506103c661079f366004614a4f565b611194565b6104746107b2366004614ab5565b6111a9565b3480156107c357600080fd5b506107cc6118e9565b60405161039d9796959493929190614af0565b3480156107eb57600080fd5b506006610561565b3480156107ff57600080fd5b506104497f000000000000000000000000a52971c0947bc4dcc9a69581296dad91bb2c8a5981565b34801561083357600080fd5b506000546001600160a01b0316610449565b61041b610853366004614b89565b61192f565b34801561086457600080fd5b50610390611a05565b34801561087957600080fd5b5061041b7f000000000000000000000000000000000000000000000000000000e8d4a5100081565b3480156108ad57600080fd5b5060006103c6565b3480156108c157600080fd5b506103c66108d03660046146ed565b611a14565b3480156108e157600080fd5b50600254610449906001600160a01b031681565b34801561090157600080fd5b50610474610910366004614c0f565b611a22565b34801561092157600080fd5b5061041b610930366004614c50565b60016020526000908152604090205481565b34801561094e57600080fd5b5061039061095d366004614c6b565b611a3c565b610474610970366004614c0f565b611be4565b34801561098157600080fd5b50610474611d6e565b61099d610998366004614ccd565b611e65565b60405161039d929190614d2f565b3480156109b757600080fd5b506104746109c6366004614a32565b611f60565b6104746109d9366004614852565b611fb6565b3480156109ea57600080fd5b5061041b600f5481565b348015610a0057600080fd5b50610474610a0f366004614a32565b611fe5565b348015610a2057600080fd5b50610474610a2f366004614d90565b61203b565b348015610a4057600080fd5b5061041b610a4f366004614e01565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205490565b348015610a8657600080fd5b50610474610a95366004614a32565b612175565b348015610aa657600080fd5b506103c6610ab5366004614e2f565b6121b0565b606060088054610ac990614e4b565b80601f0160208091040260200160405190810160405280929190818152602001828054610af590614e4b565b8015610b425780601f10610b1757610100808354040283529160200191610b42565b820191906000526020600020905b815481529060010190602001808311610b2557829003601f168201915b5050505050905090565b600033610b5a8185856121e6565b60019150505b92915050565b60408051808201909152600080825260208201526060610b99604051806040016040528060008152602001600081525090565b60408051808201825260008082526001600160401b03602080840182905284518381529081019094529195509182610bf4565b604080518082019091526000815260606020820152815260200190600190039081610bcc5790505b509350600080610c19604089013560608a0135610c1460208c018c614c50565b6121f8565b60408051808201909152918252602082015296989597505050505050565b7f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b03163314610c87576040516391ac5e4f60e01b81523360048201526024015b60405180910390fd5b60208701803590610ca190610c9c908a614c50565b61223c565b14610cdf57610cb36020880188614c50565b60405163309afaf360e21b815263ffffffff909116600482015260208801356024820152604401610c7e565b610cee87878787878787612278565b50505050505050565b600033610d058582856123df565b610d1085858561245d565b60019150505b9392505050565b610d256124bc565b600f5415610d595760405162461bcd60e51b81526020600482015260016024820152602360f91b6044820152606401610c7e565b42601055600f81905560405163133f757160e31b815260048101829052600090819081907f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b0316906399fbab889060240161018060405180830381865afa158015610dcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df39190614edc565b5050601180546001600160a01b03808b166001600160a01b0319928316811790935560128054828c169316831790556013805462ffffff808c16600160a01b90810262ffffff60a01b199093169290921792839055604051630b4c774160e11b81526004810196909652602486019490945290049091166044830152989d50969b50949950507f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f9849095169650631698ee8295505060649092019250610eb6915050565b602060405180830381865afa158015610ed3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef79190614fbd565b601380546001600160a01b0319166001600160a01b039283161790557f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88166323b872dd336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015230602482015260448101879052606401600060405180830381600087803b158015610f8957600080fd5b505af1158015610f9d573d6000803e3d6000fd5b5050505050505050565b610faf6124bc565b610fb982826124e9565b5050565b6000610fc761253e565b905090565b60408051808201909152600080825260208201526000610ffc60408501356060860135610c146020880188614c50565b91505060008061100c8684612669565b90925090506110296110216020880188614c50565b83838861278d565b9695505050505050565b61103d338261286e565b50565b60036020908152600092835260408084209091529082529020805461106490614e4b565b80601f016020809104026020016040519081016040528092919081815260200182805461109090614e4b565b80156110dd5780601f106110b2576101008083540402835291602001916110dd565b820191906000526020600020905b8154815290600101906020018083116110c057829003601f168201915b505050505081565b6110ed6124bc565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527ff0be4f1e87349231d80c36b33f9e8639658eeaf474014dee15a3e6a4d4414197906020015b60405180910390a150565b61114a6124bc565b61115460006128a4565b565b60606040518060600160405280602881526020016159e260289139905090565b6001600160a01b0381166000908152600c6020526040812054610b60565b6001600160a01b03811630145b949350505050565b6000600f54116111e15760405162461bcd60e51b81526020600482015260036024820152620494c560ec1b6044820152606401610c7e565b6011546001600160a01b038581169116148061120a57506012546001600160a01b038581169116145b61123a5760405162461bcd60e51b81526020600482015260016024820152600560fc1b6044820152606401610c7e565b60003411801561124a5750600083115b61127b5760405162461bcd60e51b8152602060048201526002602482015261444160f01b6044820152606401610c7e565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa1580156112c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e69190614fda565b905060006112f43447615009565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a0823190602401602060405180830381865afa15801561135e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113829190614fda565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156113df57600080fd5b505af11580156113f3573d6000803e3d6000fd5b50505050506114146114023390565b6001600160a01b0389169030896128f4565b6011546000906001600160a01b038981169116146114325734611434565b865b6011549091506000906001600160a01b038a81169116146114555787611457565b345b6011549091506000906001600160a01b038b8116911614611478578661147a565b875b6011549091506000906001600160a01b038c811691161461149b578861149d565b875b6011549091506114d7906001600160a01b03167f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe888661295b565b60125461150e906001600160a01b03167f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe888561295b565b6040805160c081018252600f5481526020810186815281830186815260608301868152608084018681524260a08601908152955163219f5d1760e01b8152945160048601529251602485015290516044840152516064830152516084820152905160a48201526001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88169063219f5d179060c4016060604051808303816000875af11580156115c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115eb919061501c565b505060115461162691506001600160a01b03167f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8860006129e5565b60125461165e906001600160a01b03167f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8860006129e5565b6040516370a0823160e01b81523060048201526000906001600160a01b038d16906370a0823190602401602060405180830381865afa1580156116a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c99190614fda565b9050878111156116f2576116f2336116e18a84615009565b6001600160a01b038f169190612ade565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316906370a0823190602401602060405180830381865afa158015611759573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177d9190614fda565b9050868111156118da576001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216632e1a7d4d6117c08984615009565b6040518263ffffffff1660e01b81526004016117de91815260200190565b600060405180830381600087803b1580156117f857600080fd5b505af115801561180c573d6000803e3d6000fd5b5050505060006118193390565b6001600160a01b031661182c8984615009565b604051600081818185875af1925050503d8060008114611868576040519150601f19603f3d011682016040523d82523d6000602084013e61186d565b606091505b50509050806118a35760405162461bcd60e51b8152602060048201526002602482015261534560f01b6044820152606401610c7e565b884710156118d85760405162461bcd60e51b8152602060048201526002602482015261564560f01b6044820152606401610c7e565b505b50505050505050505050505050565b6000606080600080600060606118fd612b0f565b611905612b3c565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b60008034116119645760405162461bcd60e51b81526020600482015260016024820152604560f81b6044820152606401610c7e565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156119bf57600080fd5b505af11580156119d3573d6000803e3d6000fd5b50505050506111a17f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc285348686612b69565b606060098054610ac990614e4b565b600033610b5a81858561245d565b611a2a6124bc565b610fb9611a3782846150f2565b612caf565b63ffffffff8416600090815260036020908152604080832061ffff87168452909152812080546060929190611a7090614e4b565b80601f0160208091040260200160405190810160405280929190818152602001828054611a9c90614e4b565b8015611ae95780601f10611abe57610100808354040283529160200191611ae9565b820191906000526020600020905b815481529060010190602001808311611acc57829003601f168201915b505050505090508051600003611b395783838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509294506111a19350505050565b6000839003611b495790506111a1565b60028310611bc757611b9084848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612db692505050565b80611b9e8460028188615209565b604051602001611bb093929190615233565b6040516020818303038152906040529150506111a1565b8383604051639a6d49cd60e01b8152600401610c7e929190615284565b60005b81811015611ced5736838383818110611c0257611c02615298565b9050602002810190611c1491906152ae565b9050611c47611c266020830183614c50565b602083013563ffffffff919091166000908152600160205260409020541490565b611c515750611ce5565b3063d045a0dc60c08301358360a0810135611c706101008301836152cf565b611c81610100890160e08a01614a32565b611c8f6101208a018a6152cf565b6040518963ffffffff1660e01b8152600401611cb1979695949392919061532a565b6000604051808303818588803b158015611cca57600080fd5b505af1158015611cde573d6000803e3d6000fd5b5050505050505b600101611be7565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611d2c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d5491908101906153b0565b604051638351eea760e01b8152600401610c7e91906146c5565b600d54611d7e9062278d0061541d565b4211611db05760405162461bcd60e51b81526020600482015260016024820152604960f81b6044820152606401610c7e565b600f805460009091556040516323b872dd60e01b81523060048201526001600160a01b037f0000000000000000000000005cc3488c10e76a837feae51f94fdd50acfe57c4b81166024830152604482018390527f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8816906323b872dd906064015b600060405180830381600087803b158015611e4a57600080fd5b505af1158015611e5e573d6000803e3d6000fd5b5050505050565b611e6d61462e565b6040805180820190915260008082526020820152600080611ea433604089013560608a0135611e9f60208c018c614c50565b612de2565b91509150600080611eb58984612669565b9092509050611ee1611eca60208b018b614c50565b8383611edb368d90038d018d615430565b8b612e08565b60408051808201909152858152602080820186905282519298509096503391907f85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a90611f2f908d018d614c50565b6040805163ffffffff909216825260208201899052810187905260600160405180910390a350505050935093915050565b611f686124bc565b60405163ca5eb5e160e01b81526001600160a01b0382811660048301527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c169063ca5eb5e190602401611e30565b333014611fd65760405163029a949d60e31b815260040160405180910390fd5b610cee87878787878787610cdf565b611fed6124bc565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c242776090602001611137565b8342111561205f5760405163313c898160e11b815260048101859052602401610c7e565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886120ac8c6001600160a01b03166000908152600c6020526040902080546001810190915590565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050600061210782612f13565b9050600061211782878787612f40565b9050896001600160a01b0316816001600160a01b03161461215e576040516325c0072360e11b81526001600160a01b0380831660048301528b166024820152604401610c7e565b6121698a8a8a6121e6565b50505050505050505050565b61217d6124bc565b6001600160a01b0381166121a757604051631e4fbdf760e01b815260006004820152602401610c7e565b61103d816128a4565b60006020820180359060019083906121c89086614c50565b63ffffffff1681526020810191909152604001600020541492915050565b6121f38383836001612f6e565b505050565b60008061220485613043565b915081905083811015612234576040516371c4efed60e01b81526004810182905260248101859052604401610c7e565b935093915050565b63ffffffff811660009081526001602052604081205480610b605760405163f6ff4fb760e01b815263ffffffff84166004820152602401610c7e565b600061228a612287878761307a565b90565b905060006122b6826122a461229f8a8a613092565b6130b5565b6122b160208d018d614c50565b6130ea565b9050602886111561237d5760006122f36122d660608c0160408d01615462565b6122e360208d018d614c50565b846122ee8c8c6130fe565b613149565b604051633e5ac80960e11b81529091506001600160a01b037f0000000000000000000000001a44076050125825900e736c501f859c50fe728c1690637cb59012906123499086908d90600090879060040161547f565b600060405180830381600087803b15801561236357600080fd5b505af1158015612377573d6000803e3d6000fd5b50505050505b6001600160a01b038216887fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c6123b660208d018d614c50565b6040805163ffffffff9092168252602082018690520160405180910390a3505050505050505050565b6001600160a01b038381166000908152600660209081526040808320938616835292905220546000198114612457578181101561244857604051637dc7a0d960e11b81526001600160a01b03841660048201526024810182905260448101839052606401610c7e565b61245784848484036000612f6e565b50505050565b6001600160a01b03831661248757604051634b637e8f60e11b815260006004820152602401610c7e565b6001600160a01b0382166124b15760405163ec442f0560e01b815260006004820152602401610c7e565b6121f383838361317b565b6000546001600160a01b031633146111545760405163118cdaa760e01b8152336004820152602401610c7e565b63ffffffff8216600081815260016020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b910160405180910390a15050565b6000306001600160a01b037f0000000000000000000000007a569bff9f87b526b39331ca870516c1d93c0fda1614801561259757507f000000000000000000000000000000000000000000000000000000000000000146145b156125c157507f19db02b959046b6d1f85a70060703c5ef3acf6651b3109e8227817a5de87f37090565b610fc7604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527faf837be75f84b9ed72057d3d994e80dcce20842e991878d20d05f3c05309d5b7918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60608060006126c6856020013561267f86613298565b61268c60a08901896152cf565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506132c492505050565b90935090506000816126d95760016126dc565b60025b90506126fc6126ee6020880188614c50565b8261095d60808a018a6152cf565b6004549093506001600160a01b031615612784576004805460405163043a78eb60e01b81526001600160a01b039091169163043a78eb916127419188918891016154b0565b602060405180830381865afa15801561275e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278291906154d5565b505b50509250929050565b60408051808201909152600080825260208201527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b031663ddc28c586040518060a001604052808863ffffffff1681526020016127f08961223c565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b81526004016128259291906154f2565b6040805180830381865afa158015612841573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612865919061559b565b95945050505050565b6001600160a01b03821661289857604051634b637e8f60e11b815260006004820152602401610c7e565b610fb98260008361317b565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b0384811660248301528381166044830152606482018390526124579186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061333e565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156129ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129cf9190614fda565b905061245784846129e0858561541d565b6133a1565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691612a4191906155b7565b6000604051808303816000865af19150503d8060008114612a7e576040519150601f19603f3d011682016040523d82523d6000602084013e612a83565b606091505b5091509150818015612aad575080511580612aad575080806020019051810190612aad91906154d5565b611e5e5760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401610c7e565b6040516001600160a01b038381166024830152604482018390526121f391859182169063a9059cbb90606401612929565b6060610fc77f50726f6a656374204d756c6c657400000000000000000000000000000000000e600a613431565b6060610fc77f3100000000000000000000000000000000000000000000000000000000000001600b613431565b6000612b9f6001600160a01b0387167f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc458661295b565b6040805160e0810182526001600160a01b03888116825287811660208301908152601354600160a01b900462ffffff90811684860190815287841660608601908152608086018b815260a087018b8152600060c0890190815298516304e45aaf60e01b8152975187166004890152945186166024880152915190921660448601529051831660648501525160848401525160a48301529151821660c48201527f00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45909116906304e45aaf9060e4016020604051808303816000875af1158015612c8b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110299190614fda565b60005b8151811015612d8657612ce1828281518110612cd057612cd0615298565b602002602001015160400151612db6565b818181518110612cf357612cf3615298565b60200260200101516040015160036000848481518110612d1557612d15615298565b60200260200101516000015163ffffffff1663ffffffff1681526020019081526020016000206000848481518110612d4f57612d4f615298565b60200260200101516020015161ffff1661ffff1681526020019081526020016000209081612d7d9190615611565b50600101612cb2565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b6748160405161113791906156d0565b600281015161ffff8116600314610fb95781604051639a6d49cd60e01b8152600401610c7e91906146c5565b600080612df08585856121f8565b9092509050612dff868361286e565b94509492505050565b612e1061462e565b6000612e1f84600001516134dc565b602085015190915015612e3957612e398460200151613504565b7f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b0316632637a450826040518060a001604052808b63ffffffff168152602001612e898c61223c565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b8152600401612ec59291906154f2565b60806040518083038185885af1158015612ee3573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612f08919061575b565b979650505050505050565b6000610b60612f2061253e565b8360405161190160f01b8152600281019290925260228201526042902090565b600080600080612f52888888886135e6565b925092509250612f6282826136b5565b50909695505050505050565b6001600160a01b038416612f985760405163e602df0560e01b815260006004820152602401610c7e565b6001600160a01b038316612fc257604051634a1406b160e11b815260006004820152602401610c7e565b6001600160a01b038085166000908152600660209081526040808320938716835292905220829055801561245757826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161303591815260200190565b60405180910390a350505050565b60007f000000000000000000000000000000000000000000000000000000e8d4a5100061307081846157bb565b610b6091906157cf565b60006130896020828486615209565b610d16916157e6565b60006130a2602860208486615209565b6130ab91615804565b60c01c9392505050565b6000610b607f000000000000000000000000000000000000000000000000000000e8d4a510006001600160401b0384166157cf565b60006130f6848461376e565b509092915050565b606061310d8260288186615209565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929695505050505050565b6060848484846040516020016131629493929190615834565b6040516020818303038152906040529050949350505050565b6131836137a4565b61318b613b02565b4715613206577f000000000000000000000000a52971c0947bc4dcc9a69581296dad91bb2c8a596001600160a01b031663152111f7476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156131ec57600080fd5b505af1158015613200573d6000803e3d6000fd5b50505050505b60006132128483613be5565b9050801561327057613245847f0000000000000000000000005cc3488c10e76a837feae51f94fdd50acfe57c4b83613c4e565b613270847f0000000000000000000000005cc3488c10e76a837feae51f94fdd50acfe57c4b83613d78565b613284848461327f8486615009565b613c4e565b61245784846132938486615009565b613d78565b6000610b607f000000000000000000000000000000000000000000000000000000e8d4a51000836157bb565b805160609015158061330d5784846040516020016132f992919091825260c01b6001600160c01b031916602082015260280190565b604051602081830303815290604052613334565b848433856040516020016133249493929190615883565b6040516020818303038152906040525b9150935093915050565b60006133536001600160a01b03841683613f82565b9050805160001415801561337857508080602001905181019061337691906154d5565b155b156121f357604051635274afe760e01b81526001600160a01b0384166004820152602401610c7e565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526133f28482613f90565b612457576040516001600160a01b0384811660248301526000604483015261342791869182169063095ea7b390606401612929565b612457848261333e565b606060ff831461344b5761344483614033565b9050610b60565b81805461345790614e4b565b80601f016020809104026020016040519081016040528092919081815260200182805461348390614e4b565b80156134d05780601f106134a5576101008083540402835291602001916134d0565b820191906000526020600020905b8154815290600101906020018083116134b357829003601f168201915b50505050509050610b60565b6000813414613500576040516304fb820960e51b8152346004820152602401610c7e565b5090565b60007f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b031663e4fe1d946040518163ffffffff1660e01b8152600401602060405180830381865afa158015613564573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135889190614fbd565b90506001600160a01b0381166135b1576040516329b99a9560e11b815260040160405180910390fd5b610fb96001600160a01b038216337f0000000000000000000000001a44076050125825900e736c501f859c50fe728c856128f4565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561362157506000915060039050826136ab565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015613675573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166136a1575060009250600191508290506136ab565b9250600091508190505b9450945094915050565b60008260038111156136c9576136c96158c6565b036136d2575050565b60018260038111156136e6576136e66158c6565b036137045760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115613718576137186158c6565b036137395760405163fce698f760e01b815260048101829052602401610c7e565b600382600381111561374d5761374d6158c6565b03610fb9576040516335e2f38360e21b815260048101829052602401610c7e565b6001600160a01b0382166137985760405163ec442f0560e01b815260006004820152602401610c7e565b610fb96000838361317b565b600f546000036137b057565b7f0000000000000000000000000000000000000000000000000000000000000e10600d546137de919061541d565b4210156137e757565b60135460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa158015613831573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385591906158dc565b9650505050505050806138655750565b600080613870614072565b91509150816000148015613882575080155b1561388c57505050565b6011546000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b039081169116146138d6576011546001600160a01b03166138e3565b6012546001600160a01b03165b6011549091506000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b039081169116146139255783613927565b825b9050801561395f5761395d827f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc283600030612b69565b505b6040516370a0823160e01b81523060048201526000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316906370a0823190602401602060405180830381865afa1580156139c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ea9190614fda565b90508015613a6d57604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015613a5457600080fd5b505af1158015613a68573d6000803e3d6000fd5b505050505b6000613a7a600a476157bb565b90508015610cee5760007f0000000000000000000000005cc3488c10e76a837feae51f94fdd50acfe57c4b6001600160a01b03168260405160006040518083038185875af1925050503d8060008114613aef576040519150601f19603f3d011682016040523d82523d6000602084013e613af4565b606091505b5050905080610f9d57600080fd5b600f54600003613b0e57565b7f0000000000000000000000000000000000000000000000000000000000015180600e54613b3c919061541d565b421015613b4557565b600d54600e541180613b585750600d5442145b15613b5f57565b60135460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa158015613ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bcd91906158dc565b965050505050505080613bdd5750565b61103d614158565b600080600f54118015613bf85750600082115b8015613c1157506013546001600160a01b038481169116145b8015613c2a575060b4601054613c27919061541d565b42105b15610b6057613c3a6005836157bb565b90508015613c485780610d16565b50919050565b6001600160a01b038316613c79578060076000828254613c6e919061541d565b90915550613ceb9050565b6001600160a01b03831660009081526005602052604090205481811015613ccc5760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401610c7e565b6001600160a01b03841660009081526005602052604090209082900390555b6001600160a01b038216613d0757600780548290039055613d26565b6001600160a01b03821660009081526005602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051613d6b91815260200190565b60405180910390a3505050565b6001600160a01b03831660009081526014602052604090205460ff16613edd576040516315dfa99560e11b81526001600160a01b0384811660048301527f000000000000000000000000a52971c0947bc4dcc9a69581296dad91bb2c8a591690632bbf532a90602401602060405180830381865afa158015613dfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e2291906154d5565b613e535760405162461bcd60e51b81526020600482015260026024820152614c4b60f01b6044820152606401610c7e565b6040516315dd37b360e01b81526001600160a01b03848116600483015260248201839052600160448301527f000000000000000000000000a52971c0947bc4dcc9a69581296dad91bb2c8a5916906315dd37b390606401600060405180830381600087803b158015613ec457600080fd5b505af1158015613ed8573d6000803e3d6000fd5b505050505b6001600160a01b03821660009081526014602052604090205460ff166121f3576040516315dd37b360e01b81526001600160a01b03838116600483015260248201839052600060448301527f000000000000000000000000a52971c0947bc4dcc9a69581296dad91bb2c8a5916906315dd37b390606401600060405180830381600087803b158015613f6e57600080fd5b505af1158015610cee573d6000803e3d6000fd5b6060610d16838360006144ee565b6000806000846001600160a01b031684604051613fad91906155b7565b6000604051808303816000865af19150503d8060008114613fea576040519150601f19603f3d011682016040523d82523d6000602084013e613fef565b606091505b509150915081801561401957508051158061401957508080602001905181019061401991906154d5565b80156128655750505050506001600160a01b03163b151590565b6060600061404083614581565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b42600d5560408051608081018252600f54815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b0390811660248501529151811660448401529251909216606482015260009182917f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe889091169063fc6f78659060840160408051808303816000875af115801561412b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061414f9190615974565b90939092509050565b42600e55600f5460405163133f757160e31b81526000916001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8816916399fbab88916141b09160040190815260200190565b61018060405180830381865afa1580156141ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141f29190614edc565b505050509750505050505050507f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b0316630c49ccbe6040518060a00160405280600f54815260200160647f000000000000000000000000000000000000000000000000000000000000000360ff16866142729190615998565b61427c91906159bb565b6001600160801b031681526020016000815260200160008152602001428152506040518263ffffffff1660e01b81526004016142f69190600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b60408051808303816000875af1158015614314573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143389190615974565b5050600080614345614072565b60115491935091506000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03908116911614614394576011546001600160a01b03166143a1565b6012546001600160a01b03165b6011549091506000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b039081169116146143e357826143e5565b835b9050801561441d5761441b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28383600030612b69565b505b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015614464573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144889190614fda565b905080156144e657604051630852cd8d60e31b8152600481018290526001600160a01b038416906342966c6890602401600060405180830381600087803b1580156144d257600080fd5b505af1158015612169573d6000803e3d6000fd5b505050505050565b6060814710156145135760405163cd78605960e01b8152306004820152602401610c7e565b600080856001600160a01b0316848660405161452f91906155b7565b60006040518083038185875af1925050503d806000811461456c576040519150601f19603f3d011682016040523d82523d6000602084013e614571565b606091505b50915091506110298683836145a9565b600060ff8216601f811115610b6057604051632cd44ac360e21b815260040160405180910390fd5b6060826145be576145b982614605565b610d16565b81511580156145d557506001600160a01b0384163b155b156145fe57604051639996b31560e01b81526001600160a01b0385166004820152602401610c7e565b5080610d16565b8051156146155780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60405180606001604052806000801916815260200160006001600160401b03168152602001614670604051806040016040528060008152602001600081525090565b905290565b60005b83811015614690578181015183820152602001614678565b50506000910152565b600081518084526146b1816020860160208601614675565b601f01601f19169290920160200192915050565b602081526000610d166020830184614699565b6001600160a01b038116811461103d57600080fd5b6000806040838503121561470057600080fd5b823561470b816146d8565b946020939093013593505050565b600060e08284031215613c4857600080fd5b60006020828403121561473d57600080fd5b81356001600160401b0381111561475357600080fd5b6111a184828501614719565b8351815260208085015190820152600060a08201604060a0604085015281865180845260c08601915060c08160051b8701019350602080890160005b838110156147da5788870360bf190185528151805188528301518388018790526147c787890182614699565b975050938201939082019060010161479b565b505087516060880152505050602085015160808501525090506111a1565b600060608284031215613c4857600080fd5b60008083601f84011261481c57600080fd5b5081356001600160401b0381111561483357600080fd5b60208301915083602082850101111561484b57600080fd5b9250929050565b600080600080600080600060e0888a03121561486d57600080fd5b61487789896147f8565b96506060880135955060808801356001600160401b038082111561489a57600080fd5b6148a68b838c0161480a565b909750955060a08a013591506148bb826146d8565b90935060c089013590808211156148d157600080fd5b506148de8a828b0161480a565b989b979a50959850939692959293505050565b60008060006060848603121561490657600080fd5b8335614911816146d8565b92506020840135614921816146d8565b929592945050506040919091013590565b60006020828403121561494457600080fd5b5035919050565b803563ffffffff8116811461495f57600080fd5b919050565b6000806040838503121561497757600080fd5b61470b8361494b565b801515811461103d57600080fd5b600080604083850312156149a157600080fd5b82356001600160401b038111156149b757600080fd5b6149c385828601614719565b92505060208301356149d481614980565b809150509250929050565b815181526020808301519082015260408101610b60565b61ffff8116811461103d57600080fd5b60008060408385031215614a1957600080fd5b614a228361494b565b915060208301356149d4816149f6565b600060208284031215614a4457600080fd5b8135610d16816146d8565b60008060008060a08587031215614a6557600080fd5b614a6f86866147f8565b935060608501356001600160401b03811115614a8a57600080fd5b614a968782880161480a565b9094509250506080850135614aaa816146d8565b939692955090935050565b60008060008060808587031215614acb57600080fd5b8435614ad6816146d8565b966020860135965060408601359560600135945092505050565b60ff60f81b881681526000602060e06020840152614b1160e084018a614699565b8381036040850152614b23818a614699565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015614b7757835183529284019291840191600101614b5b565b50909c9b505050505050505050505050565b600080600060608486031215614b9e57600080fd5b8335614ba9816146d8565b9250602084013591506040840135614bc0816146d8565b809150509250925092565b60008083601f840112614bdd57600080fd5b5081356001600160401b03811115614bf457600080fd5b6020830191508360208260051b850101111561484b57600080fd5b60008060208385031215614c2257600080fd5b82356001600160401b03811115614c3857600080fd5b614c4485828601614bcb565b90969095509350505050565b600060208284031215614c6257600080fd5b610d168261494b565b60008060008060608587031215614c8157600080fd5b614c8a8561494b565b93506020850135614c9a816149f6565b925060408501356001600160401b03811115614cb557600080fd5b614cc18782880161480a565b95989497509550505050565b60008060008385036080811215614ce357600080fd5b84356001600160401b03811115614cf957600080fd5b614d0587828801614719565b9450506040601f1982011215614d1a57600080fd5b506020840191506060840135614bc0816146d8565b600060c082019050835182526001600160401b0360208501511660208301526040840151614d6a604084018280518252602090810151910152565b5082516080830152602083015160a0830152610d16565b60ff8116811461103d57600080fd5b600080600080600080600060e0888a031215614dab57600080fd5b8735614db6816146d8565b96506020880135614dc6816146d8565b955060408801359450606088013593506080880135614de481614d81565b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215614e1457600080fd5b8235614e1f816146d8565b915060208301356149d4816146d8565b600060608284031215614e4157600080fd5b610d1683836147f8565b600181811c90821680614e5f57607f821691505b602082108103613c4857634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b805161495f816146d8565b805162ffffff8116811461495f57600080fd5b8051600281900b811461495f57600080fd5b80516001600160801b038116811461495f57600080fd5b6000806000806000806000806000806000806101808d8f031215614eff57600080fd5b8c516bffffffffffffffffffffffff81168114614f1b57600080fd5b9b50614f2960208e01614e95565b9a50614f3760408e01614e95565b9950614f4560608e01614e95565b9850614f5360808e01614ea0565b9750614f6160a08e01614eb3565b9650614f6f60c08e01614eb3565b9550614f7d60e08e01614ec5565b94506101008d015193506101208d01519250614f9c6101408e01614ec5565b9150614fab6101608e01614ec5565b90509295989b509295989b509295989b565b600060208284031215614fcf57600080fd5b8151610d16816146d8565b600060208284031215614fec57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610b6057610b60614ff3565b60008060006060848603121561503157600080fd5b61503a84614ec5565b925060208401519150604084015190509250925092565b604051606081016001600160401b038111828210171561507357615073614e7f565b60405290565b604080519081016001600160401b038111828210171561507357615073614e7f565b604051601f8201601f191681016001600160401b03811182821017156150c3576150c3614e7f565b604052919050565b60006001600160401b038211156150e4576150e4614e7f565b50601f01601f191660200190565b60006001600160401b038084111561510c5761510c614e7f565b8360051b602061511d81830161509b565b86815291850191818101903684111561513557600080fd5b865b848110156151fd5780358681111561514f5760008081fd5b880160603682900312156151635760008081fd5b61516b615051565b6151748261494b565b815285820135615183816149f6565b818701526040828101358981111561519b5760008081fd5b929092019136601f8401126151b05760008081fd5b82356151c36151be826150cb565b61509b565b81815236898387010111156151d85760008081fd5b818986018a830137600091810189019190915290820152845250918301918301615137565b50979650505050505050565b6000808585111561521957600080fd5b8386111561522657600080fd5b5050820193919092039150565b60008451615245818460208901614675565b8201838582376000930192835250909392505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6020815260006111a160208301848661525b565b634e487b7160e01b600052603260045260246000fd5b6000823561013e198336030181126152c557600080fd5b9190910192915050565b6000808335601e198436030181126152e657600080fd5b8301803591506001600160401b0382111561530057600080fd5b60200191503681900382131561484b57600080fd5b6001600160401b038116811461103d57600080fd5b63ffffffff6153388961494b565b168152602088013560208201526000604089013561535581615315565b6001600160401b03811660408401525087606083015260e0608083015261538060e08301878961525b565b6001600160a01b03861660a084015282810360c08401526153a281858761525b565b9a9950505050505050505050565b6000602082840312156153c257600080fd5b81516001600160401b038111156153d857600080fd5b8201601f810184136153e957600080fd5b80516153f76151be826150cb565b81815285602083850101111561540c57600080fd5b612865826020830160208601614675565b80820180821115610b6057610b60614ff3565b60006040828403121561544257600080fd5b61544a615079565b82358152602083013560208201528091505092915050565b60006020828403121561547457600080fd5b8135610d1681615315565b60018060a01b038516815283602082015261ffff831660408201526080606082015260006110296080830184614699565b6040815260006154c36040830185614699565b82810360208401526128658185614699565b6000602082840312156154e757600080fd5b8151610d1681614980565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a0608084015261552860e0840182614699565b90506060850151603f198483030160a08501526155458282614699565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b60006040828403121561557d57600080fd5b615585615079565b9050815181526020820151602082015292915050565b6000604082840312156155ad57600080fd5b610d16838361556b565b600082516152c5818460208701614675565b601f8211156121f3576000816000526020600020601f850160051c810160208610156155f25750805b601f850160051c820191505b818110156144e6578281556001016155fe565b81516001600160401b0381111561562a5761562a614e7f565b61563e816156388454614e4b565b846155c9565b602080601f831160018114615673576000841561565b5750858301515b600019600386901b1c1916600185901b1785556144e6565b600085815260208120601f198616915b828110156156a257888601518255948401946001909101908401615683565b50858210156156c05787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561574d57888303603f190185528151805163ffffffff1684528781015161ffff1688850152860151606087850181905261573981860183614699565b9689019694505050908601906001016156f9565b509098975050505050505050565b60006080828403121561576d57600080fd5b615775615051565b82518152602083015161578781615315565b6020820152615799846040850161556b565b60408201529392505050565b634e487b7160e01b600052601260045260246000fd5b6000826157ca576157ca6157a5565b500490565b8082028115828204841417610b6057610b60614ff3565b80356020831015610b6057600019602084900360031b1b1692915050565b6001600160c01b0319813581811691600885101561582c5780818660080360031b1b83161692505b505092915050565b6001600160401b0360c01b8560c01b16815263ffffffff60e01b8460e01b16600882015282600c8201526000825161587381602c850160208701614675565b91909101602c0195945050505050565b8481526001600160401b0360c01b8460c01b166020820152826028820152600082516158b6816048850160208701614675565b9190910160480195945050505050565b634e487b7160e01b600052602160045260246000fd5b600080600080600080600060e0888a0312156158f757600080fd5b8751615902816146d8565b965061591060208901614eb3565b95506040880151615920816149f6565b6060890151909550615931816149f6565b6080890151909450615942816149f6565b60a089015190935061595381614d81565b60c089015190925061596481614980565b8091505092959891949750929550565b6000806040838503121561598757600080fd5b505080516020909101519092909150565b6001600160801b0381811683821602808216919082811461582c5761582c614ff3565b60006001600160801b03808416806159d5576159d56157a5565b9216919091049291505056fe427573696e65737320696e207468652066726f6e742c20706172747920696e20746865206261636ba164736f6c6343000818000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe880000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98400000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc450000000000000000000000001a44076050125825900e736c501f859c50fe728c0000000000000000000000005cc3488c10e76a837feae51f94fdd50acfe57c4b
-----Decoded View---------------
Arg [0] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _lpManager (address): 0xC36442b4a4522E871399CD717aBDD847Ab11FE88
Arg [2] : _v3Factory (address): 0x1F98431c8aD98523631AE4a59f267346ea31F984
Arg [3] : _swapRouter (address): 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45
Arg [4] : _layerZeroEndpoint (address): 0x1a44076050125825900e736c501f859c50fE728c
Arg [5] : _oftAdm (address): 0x5CC3488C10E76A837fEAE51F94FDd50Acfe57c4B
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88
Arg [2] : 0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
Arg [3] : 00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45
Arg [4] : 0000000000000000000000001a44076050125825900e736c501f859c50fe728c
Arg [5] : 0000000000000000000000005cc3488c10e76a837feae51f94fdd50acfe57c4b
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.