Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 253,967 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Drive Bus | 11638231 | 17 secs ago | IN | 0.00003965 ETH | 0.00002781 | ||||
Set Fares | 11638206 | 1 min ago | IN | 0 ETH | 0.00001203 | ||||
Set Fares | 11638206 | 1 min ago | IN | 0 ETH | 0.00001203 | ||||
Set Fares | 11638206 | 1 min ago | IN | 0 ETH | 0.00001203 | ||||
Set Fares | 11638205 | 1 min ago | IN | 0 ETH | 0.00001204 | ||||
Drive Bus | 11638146 | 4 mins ago | IN | 0.00009173 ETH | 0.00002651 | ||||
Drive Bus | 11638108 | 6 mins ago | IN | 0.00004623 ETH | 0.00002716 | ||||
Set Fares | 11638108 | 6 mins ago | IN | 0 ETH | 0.00001094 | ||||
Set Fares | 11638108 | 6 mins ago | IN | 0 ETH | 0.00001094 | ||||
Drive Bus | 11638084 | 7 mins ago | IN | 0.00004049 ETH | 0.00003377 | ||||
Drive Bus | 11638069 | 8 mins ago | IN | 0.00001959 ETH | 0.00003434 | ||||
Drive Bus | 11638065 | 8 mins ago | IN | 0.00004623 ETH | 0.00003061 | ||||
Drive Bus | 11638026 | 10 mins ago | IN | 0.00012446 ETH | 0.00002862 | ||||
Drive Bus | 11638015 | 11 mins ago | IN | 0.00004623 ETH | 0.00003015 | ||||
Set Fares | 11638008 | 11 mins ago | IN | 0 ETH | 0.00001186 | ||||
Drive Bus | 11637989 | 12 mins ago | IN | 0.00004049 ETH | 0.00003054 | ||||
Drive Bus | 11637960 | 14 mins ago | IN | 0.00003588 ETH | 0.00002927 | ||||
Drive Bus | 11637953 | 14 mins ago | IN | 0.00004623 ETH | 0.00003048 | ||||
Set Fares | 11637909 | 16 mins ago | IN | 0 ETH | 0.00001242 | ||||
Drive Bus | 11637904 | 16 mins ago | IN | 0.00004508 ETH | 0.00002927 | ||||
Drive Bus | 11637902 | 16 mins ago | IN | 0.00001945 ETH | 0.00002889 | ||||
Drive Bus | 11637838 | 20 mins ago | IN | 0.0001092 ETH | 0.00002641 | ||||
Set Fares | 11637811 | 21 mins ago | IN | 0 ETH | 0.00001149 | ||||
Set Fares | 11637811 | 21 mins ago | IN | 0 ETH | 0.00001149 | ||||
Drive Bus | 11637798 | 22 mins ago | IN | 0.00001959 ETH | 0.0000274 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
11638234 | 8 secs ago | 0.00003086 ETH | ||||
11638234 | 8 secs ago | 0.00003086 ETH | ||||
11638231 | 17 secs ago | 0.00003965 ETH | ||||
11638173 | 3 mins ago | 0.00002869 ETH | ||||
11638173 | 3 mins ago | 0.00002869 ETH | ||||
11638146 | 4 mins ago | 0.00009173 ETH | ||||
11638110 | 6 mins ago | 0.00003412 ETH | ||||
11638110 | 6 mins ago | 0.00003412 ETH | ||||
11638108 | 6 mins ago | 0.00004623 ETH | ||||
11638103 | 6 mins ago | 0.00003412 ETH | ||||
11638103 | 6 mins ago | 0.00003412 ETH | ||||
11638084 | 7 mins ago | 0.00004049 ETH | ||||
11638069 | 8 mins ago | 0.00001959 ETH | ||||
11638065 | 8 mins ago | 0.00004623 ETH | ||||
11638062 | 8 mins ago | 0.00003412 ETH | ||||
11638062 | 8 mins ago | 0.00003412 ETH | ||||
11638051 | 9 mins ago | 0.00003412 ETH | ||||
11638051 | 9 mins ago | 0.00003412 ETH | ||||
11638026 | 10 mins ago | 0.00012446 ETH | ||||
11638016 | 11 mins ago | 0.00003412 ETH | ||||
11638016 | 11 mins ago | 0.00003412 ETH | ||||
11638015 | 11 mins ago | 0.00004623 ETH | ||||
11638003 | 11 mins ago | 0.000015 ETH | ||||
11638003 | 11 mins ago | 0.000015 ETH | ||||
11637993 | 12 mins ago | 0.00002872 ETH |
Loading...
Loading
Contract Name:
TokenMessaging
Compiler Version
v0.8.22+commit.4fc1097e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { MessagingReceipt, MessagingFee } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol"; import { ITokenMessaging, TaxiParams, RideBusParams, Ticket } from "../interfaces/ITokenMessaging.sol"; import { ITokenMessagingHandler } from "../interfaces/ITokenMessagingHandler.sol"; import { BusQueue, BusLib, Bus, BusPassenger, BusCodec } from "../libs/Bus.sol"; import { Transfer } from "../libs/Transfer.sol"; import { TokenMessagingOptions } from "./TokenMessagingOptions.sol"; import { MessagingBase, Origin } from "./MessagingBase.sol"; import { TaxiCodec } from "../libs/TaxiCodec.sol"; import { AddressCast } from "../libs/AddressCast.sol"; contract TokenMessaging is Transfer, MessagingBase, TokenMessagingOptions, ITokenMessaging { /// @dev The maximum number of passengers is queueCapacity - 1 to avoid overwriting the hash root. uint16 public immutable queueCapacity; uint32 internal immutable localEid; mapping(uint32 dstEid => BusQueue queue) public busQueues; mapping(uint32 dstEid => uint128 nativeDropAmount) public nativeDropAmounts; event FaresSet(uint32 dstEid, uint80 busFare, uint80 busAndNativeDropFare); event NativeDropAmountSet(uint32 dstEid, uint128 nativeDropAmount); event MaxNumPassengersSet(uint32 dstEid, uint8 maxNumPassengers); event NativeDropApplied(address receiver, uint128 amount); event NativeDropFailed(address receiver, uint128 amount); event BusQueueStorageInitialized(uint32 dstEid, uint16 startSlot, uint16 endSlot); error Messaging_InvalidEid(); error Messaging_InvalidQueueCapacity(); error Messaging_InvalidMsgValue(); error Messaging_MaxNumPassengersExceedsQueueCapacity(); error Messaging_NotEnoughPassengers(); constructor(address _endpoint, address _owner, uint16 _queueCapacity) MessagingBase(_endpoint, _owner) { if (_queueCapacity < 2) revert Messaging_InvalidQueueCapacity(); // queue capacity must be at least 2 queueCapacity = _queueCapacity; localEid = endpoint.eid(); } // ---------------------------------- Only Owner ------------------------------------------ function setMaxNumPassengers(uint32 _dstEid, uint8 _maxNumPassengers) external onlyOwner { if (_maxNumPassengers >= queueCapacity) revert Messaging_MaxNumPassengersExceedsQueueCapacity(); busQueues[_dstEid].setMaxNumPassengers(_maxNumPassengers); emit MaxNumPassengersSet(_dstEid, _maxNumPassengers); } function setNativeDropAmount(uint32 _dstEid, uint128 _nativeDropAmount) external onlyOwner { nativeDropAmounts[_dstEid] = _nativeDropAmount; emit NativeDropAmountSet(_dstEid, _nativeDropAmount); } /// @notice Initialize the queue storage to pay the storage costs upfront /// @dev Emits BusQueueStorageInitialized per queue initialized /// @param _dstEids The endpoint IDs of the busQueues to initialize /// @param _startSlot The first slot to initialize (inclusive) /// @param _endSlot The last slot to initialize (inclusive) function initializeBusQueueStorage( uint32[] calldata _dstEids, uint16 _startSlot, uint16 _endSlot ) external onlyOwner { for (uint256 i = 0; i < _dstEids.length; i++) { BusQueue storage queue = busQueues[_dstEids[i]]; if (queue.nextTicketId + queue.qLength > queueCapacity) continue; // whole buffer already used uint16 lastTicketId = uint16(queue.nextTicketId + queue.qLength); // only initialize unused slots uint16 startSlot = _startSlot >= lastTicketId ? _startSlot : lastTicketId; // storage slots go from 0 to queueCapacity - 1 uint16 endSlot = _endSlot >= queueCapacity - 1 ? queueCapacity - 1 : _endSlot; // use a non-zero value to initialize storage between [startSlot, endSlot], both inclusive for (uint16 slot = startSlot; slot <= endSlot; slot++) { queue.hashChain[slot] = bytes32("F"); } emit BusQueueStorageInitialized(_dstEids[i], startSlot, endSlot); } } // ---------------------------------- Planner ------------------------------------------ function quoteFares( uint32 _dstEid, uint8 _numPassengers ) external view returns (uint256 busFare, uint256 busAndNativeDropFare) { if (_numPassengers == 0) revert Messaging_NotEnoughPassengers(); bytes memory mockPassengersBytes = new bytes(uint256(_numPassengers) * PASSENGER_SIZE); bytes memory message = BusCodec.encodeBus(0, 0, mockPassengersBytes); // Retrieve the LZ quote based on the busFare and NO native drop bytes memory optionsBusFare = _buildOptionsForDriveBus(_dstEid, _numPassengers, 0, 0); busFare = _quote(_dstEid, message, optionsBusFare, false).nativeFee / _numPassengers; // Retrieve the LZ quote based on the busFare and nativeDrop option bytes memory optionsBusAndNativeDropFare = _buildOptionsForDriveBus( _dstEid, _numPassengers, _numPassengers, // Assume every rider in this case is using nativeDrop nativeDropAmounts[_dstEid] ); busAndNativeDropFare = _quote(_dstEid, message, optionsBusAndNativeDropFare, false).nativeFee / _numPassengers; } // The '_busAndNativeDropFare' is the cost for riding the bus AND the native drop function setFares(uint32 _dstEid, uint80 _busFare, uint80 _busAndNativeDropFare) external onlyPlanner { // If the planner sets the bus fare with the localEid, users can ride the bus to the local endpoint, // but the bus will never be driven. if (_dstEid == localEid) revert Messaging_InvalidEid(); busQueues[_dstEid].setFares(_busFare, _busAndNativeDropFare); emit FaresSet(_dstEid, _busFare, _busAndNativeDropFare); } // ---------------------------------- Taxi ------------------------------------------ function quoteTaxi( TaxiParams calldata _params, bool _payInLzToken ) external view returns (MessagingFee memory fee) { (bytes memory message, bytes memory options) = _encodeMessageAndOptionsForTaxi(_params); fee = _quote(_params.dstEid, message, options, _payInLzToken); } function taxi( TaxiParams calldata _params, MessagingFee calldata _messagingFee, address _refundAddress ) external payable returns (MessagingReceipt memory receipt) { (bytes memory message, bytes memory options) = _encodeMessageAndOptionsForTaxi(_params); receipt = _lzSend(_params.dstEid, message, options, _messagingFee, _refundAddress); } function _encodeMessageAndOptionsForTaxi( TaxiParams calldata _params ) internal view returns (bytes memory message, bytes memory options) { uint16 assetId = _safeGetAssetId(msg.sender); message = TaxiCodec.encodeTaxi(_params.sender, assetId, _params.receiver, _params.amountSD, _params.composeMsg); options = _buildOptionsForTaxi(_params.dstEid, _params.extraOptions); } // ---------------------------------- RideBus ------------------------------------------ function quoteRideBus(uint32 _dstEid, bool _airdrop) external view returns (MessagingFee memory fee) { fee.nativeFee = busQueues[_dstEid].safeGetFare(_airdrop); } function rideBus( RideBusParams calldata _params ) external returns (MessagingReceipt memory receipt, Ticket memory ticket) { // step 1: check the msg.sender is the stargate by getting the assetId. This acts as a form of access control, // as the function will revert if the msg.sender is not a stargate. uint16 assetId = _safeGetAssetId(msg.sender); // step 2: ride the bus and get the encoded passenger bytes etc. uint32 dstEid = _params.dstEid; (uint72 ticketId, bytes memory passengerBytes, uint256 fare) = busQueues[dstEid].ride( queueCapacity, dstEid, BusPassenger({ assetId: assetId, receiver: _params.receiver, amountSD: _params.amountSD, nativeDrop: _params.nativeDrop }) ); // step 3: create the 'Ticket' which acts like a 'receipt' for the passenger ticket = Ticket(ticketId, passengerBytes); // step 4: refund any excess fare passed receipt.fee.nativeFee = fare; } function getPassengerHash(uint32 _dstEid, uint16 _index) external view returns (bytes32 hash) { hash = busQueues[_dstEid].hashChain[_index]; } // ---------------------------------- Bus ------------------------------------------ function quoteDriveBus(uint32 _dstEid, bytes calldata _passengers) external view returns (MessagingFee memory fee) { // Step 1: check the tickets Bus memory bus = busQueues[_dstEid].checkTickets(queueCapacity, _passengers); // Step 2: generate the lzMsg and lzOptions (bytes memory message, bytes memory options) = _encodeMessageAndOptionsForDriveBus(_dstEid, bus); // Step 3: quote the fee fee = _quote(_dstEid, message, options, false); } /// @dev Anyone can drive the bus with all or partial of the passengers function driveBus( uint32 _dstEid, bytes calldata _passengers ) external payable returns (MessagingReceipt memory receipt) { // Step 1: check the tickets and drive Bus memory bus = busQueues[_dstEid].checkTicketsAndDrive(queueCapacity, _passengers); // Step 2: generate the lzMsg and lzOptions (bytes memory message, bytes memory options) = _encodeMessageAndOptionsForDriveBus(_dstEid, bus); // Step 3: send the message through LZ receipt = _lzSend(_dstEid, message, options, MessagingFee(msg.value, 0), msg.sender); // Step 4: emit the bus driven event with the guid emit BusLib.BusDriven(_dstEid, bus.startTicketId, bus.numPassengers, receipt.guid); } function _encodeMessageAndOptionsForDriveBus( uint32 _dstEid, Bus memory _bus ) internal view returns (bytes memory message, bytes memory options) { // In the event that nativeDropAmount is zero, the transfer is skipped in _lzReceiveBus(...) on destination. uint128 nativeDropAmount = nativeDropAmounts[_dstEid]; message = BusCodec.encodeBus(_bus.totalNativeDrops, nativeDropAmount, _bus.passengersBytes); options = _buildOptionsForDriveBus(_dstEid, _bus.numPassengers, _bus.totalNativeDrops, nativeDropAmount); } // ---------------------------------- OApp Functions ------------------------------------------ function _lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address /*_executor*/, bytes calldata /*_extraData*/ ) internal override { if (BusCodec.isBus(_message)) { _lzReceiveBus(_origin, _guid, _message); } else { _lzReceiveTaxi(_origin, _guid, _message); } } function _lzReceiveBus(Origin calldata _origin, bytes32 _guid, bytes calldata _busBytes) internal { (uint128 totalNativeDrops, uint128 nativeDropAmount, BusPassenger[] memory passengers) = BusCodec.decodeBus( _busBytes ); if (totalNativeDrops > 0 && msg.value != (totalNativeDrops * nativeDropAmount)) revert Messaging_InvalidMsgValue(); uint256 nativeDropAmountLeft = msg.value; for (uint8 seatNumber = 0; seatNumber < passengers.length; seatNumber++) { BusPassenger memory passenger = passengers[seatNumber]; address stargate = _safeGetStargateImpl(passenger.assetId); address receiver = AddressCast.toAddress(passenger.receiver); if (nativeDropAmount > 0 && passenger.nativeDrop) { // limit the native token transfer. // if it fails, the token drop will be considered failed and the receiver will not receive the token // if the receiver is a contract with custom receive function, this might OOG if (Transfer.transferNative(receiver, nativeDropAmount, true)) { unchecked { nativeDropAmountLeft -= nativeDropAmount; } emit NativeDropApplied(receiver, nativeDropAmount); } else { emit NativeDropFailed(receiver, nativeDropAmount); } } ITokenMessagingHandler(stargate).receiveTokenBus(_origin, _guid, seatNumber, receiver, passenger.amountSD); } // refund the remaining native token to the planner without a gas limit if (nativeDropAmountLeft > 0) Transfer.safeTransferNative(planner, nativeDropAmountLeft, false); } function _lzReceiveTaxi(Origin calldata _origin, bytes32 _guid, bytes calldata _taxiBytes) internal { (uint16 assetId, bytes32 receiverBytes32, uint64 amountSD, bytes memory composeMsg) = TaxiCodec.decodeTaxi( _taxiBytes ); address receiver = AddressCast.toAddress(receiverBytes32); address stargate = _safeGetStargateImpl(assetId); ITokenMessagingHandler(stargate).receiveTokenTaxi(_origin, _guid, receiver, amountSD, composeMsg); } /// @dev The native coin is already checked in the stargate contract and transferred to this contract function _payNative(uint256 _nativeFee) internal pure override returns (uint256 nativeFee) { nativeFee = _nativeFee; } function isComposeMsgSender( Origin calldata /*_origin*/, bytes calldata _message, address _sender ) public view override returns (bool) { // only compose msgs can come from taxi, so if its not a taxi its false if (TaxiCodec.isTaxi(_message)) { (uint16 assetId, , , ) = TaxiCodec.decodeTaxi(_message); if (stargateImpls[assetId] == _sender) return true; } return false; } }
// 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 { 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; /** * @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; 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; 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.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.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; } enum ExecutionState { NotExecutable, Executable, Executed } 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); 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, address _receiveLib, bytes32 _payloadHash ) external view returns (bool); function executable(Origin calldata _origin, address _receiver) external view returns (ExecutionState); 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); // todo: move to OAppReceiver? it is just convention for executor. we may can change it in a new Receiver version 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 oldLib, 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 oldLib, 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); /// ------------------- 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); }
// 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.22; import { Errors } from "./Errors.sol"; library AddressCast { function toBytes32(bytes calldata _addressBytes) internal pure returns (bytes32 result) { if (_addressBytes.length > 32) revert Errors.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 Errors.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 Errors.InvalidAddress(); result = address(bytes20(_addressBytes)); } }
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.22; library Errors { error LzTokenUnavailable(); error OnlyAltToken(); error InvalidReceiveLibrary(); error InvalidNonce(uint64 nonce); error InvalidArgument(); error InvalidExpiry(); error InvalidAmount(uint256 required, uint256 supplied); error OnlyRegisteredOrDefaultLib(); error OnlyRegisteredLib(); error OnlyNonDefaultLib(); error Unauthorized(); error DefaultSendLibUnavailable(); error DefaultReceiveLibUnavailable(); error PathNotInitializable(); error PathNotVerifiable(); error OnlySendLib(); error OnlyReceiveLib(); error UnsupportedEid(); error UnsupportedInterface(); error AlreadyRegistered(); error SameValue(); error InvalidPayloadHash(); error PayloadHashNotFound(bytes32 expected, bytes32 actual); error ComposeNotFound(bytes32 expected, bytes32 actual); error ComposeExists(); error SendReentrancy(); error NotImplemented(); error InvalidAddress(); error InvalidSizeForAddress(); error InsufficientFee( uint256 requiredNative, uint256 suppliedNative, uint256 requiredLzToken, uint256 suppliedLzToken ); error ZeroLzTokenFee(); }
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.22; 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 v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; // Solidity does not support splitting import across multiple lines // solhint-disable-next-line max-line-length import { IOFT, SendParam, MessagingFee, MessagingReceipt, OFTReceipt } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol"; /// @notice Stargate implementation type. enum StargateType { Pool, OFT } /// @notice Ticket data for bus ride. struct Ticket { uint72 ticketId; bytes passengerBytes; } /// @title Interface for Stargate. /// @notice Defines an API for sending tokens to destination chains. interface IStargate is IOFT { /// @dev This function is same as `send` in OFT interface but returns the ticket data if in the bus ride mode, /// which allows the caller to ride and drive the bus in the same transaction. function sendToken( SendParam calldata _sendParam, MessagingFee calldata _fee, address _refundAddress ) external payable returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt, Ticket memory ticket); /// @notice Returns the Stargate implementation type. function stargateType() external pure returns (StargateType); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import { MessagingReceipt, MessagingFee, Ticket } from "./IStargate.sol"; /// @notice Payload for sending a taxi message. /// @dev A taxi message is sent immediately and is not stored on the bus. struct TaxiParams { address sender; uint32 dstEid; bytes32 receiver; uint64 amountSD; bytes composeMsg; bytes extraOptions; } /// @notice Payload for riding the bus. /// @dev Riding the bus is a two-step process: /// @dev - The message is sent to the bus, /// @dev - The bus is driven to the destination. struct RideBusParams { address sender; uint32 dstEid; bytes32 receiver; uint64 amountSD; bool nativeDrop; } /// @title Token Messaging API. /// @notice This interface defines the API for sending a taxi message, riding the bus, and driving the bus, along with /// corresponding quote functions. interface ITokenMessaging { /// @notice Sends a taxi message /// @param _params The taxi message payload /// @param _messagingFee The messaging fee for sending a taxi message /// @param _refundAddress The address to refund excess LayerZero MessagingFees /// @return receipt The MessagingReceipt resulting from sending the taxi function taxi( TaxiParams calldata _params, MessagingFee calldata _messagingFee, address _refundAddress ) external payable returns (MessagingReceipt memory receipt); /// @notice Quotes the messaging fee for sending a taxi message /// @param _params The taxi message payload /// @param _payInLzToken Whether to pay the fee in LZ token /// @return fee The MessagingFee for sending the taxi message function quoteTaxi(TaxiParams calldata _params, bool _payInLzToken) external view returns (MessagingFee memory fee); /// @notice Sends a message to ride the bus, queuing the passenger in preparation for the drive. /// @notice The planner will later driveBus to the destination endpoint. /// @param _params The rideBus message payload /// @return receipt The MessagingReceipt resulting from sending the rideBus message /// @return ticket The Ticket for riding the bus function rideBus( RideBusParams calldata _params ) external returns (MessagingReceipt memory receipt, Ticket memory ticket); /// @notice Quotes the messaging fee for riding the bus /// @param _dstEid The destination LayerZero endpoint ID. /// @param _nativeDrop Whether to pay for a native drop on the destination. /// @return fee The MessagingFee for riding the bus function quoteRideBus(uint32 _dstEid, bool _nativeDrop) external view returns (MessagingFee memory fee); /// @notice Drives the bus to the destination. /// @param _dstEid The destination LayerZero endpoint ID. /// @param _passengers The passengers to drive to the destination. /// @return receipt The MessagingReceipt resulting from driving the bus function driveBus( uint32 _dstEid, bytes calldata _passengers ) external payable returns (MessagingReceipt memory receipt); /// @notice Quotes the messaging fee for driving the bus to the destination. /// @param _dstEid The destination LayerZero endpoint ID. /// @param _passengers The passengers to drive to the destination. /// @return fee The MessagingFee for driving the bus function quoteDriveBus(uint32 _dstEid, bytes calldata _passengers) external view returns (MessagingFee memory fee); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import { Origin } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol"; /// @dev This is an internal interface, defining the function to handle token message from the token messaging contract. interface ITokenMessagingHandler { function receiveTokenBus( Origin calldata _origin, bytes32 _guid, uint8 _seatNumber, address _receiver, uint64 _amountSD ) external; function receiveTokenTaxi( Origin calldata _origin, bytes32 _guid, address _receiver, uint64 _amountSD, bytes calldata _composeMsg ) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; library AddressCast { function toBytes32(address _address) internal pure returns (bytes32 result) { result = bytes32(uint256(uint160(_address))); } function toAddress(bytes32 _addressBytes32) internal pure returns (address result) { result = address(uint160(uint256(_addressBytes32))); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { BusPassenger, BusCodec } from "./BusCodec.sol"; /* Bus Parameters There is three relevant bus parameters regarding the number of passengers than can queue up for it and later sit on it to be driven: queueCapacity maxNumPassengers plannerPassengers In simple terms, up to queueCapacity passengers can queue up at once, up to maxNumPassengers can be driven per bus at once, and plannerPassengers passengers will be driven under steady state conditions. When and how to set these parameters is explained next: queueCapacity Queue capacity is an on-chain parameter set at deployment time (it is part of the constructor). It limits the amount of passengers that can queue up for the bus at once. It also sets the size of the circular buffer used to represent the queue. The capacity impacts the cost of initialization since each capacity slot should be initialized, so it is a number that we want to bound. At the same time, the size of the circular buffer defines the bus behaviour under re-orgs: Because a re-org will re-order txs, that changes the hashChain, which will cause the `drive` txs to revert as they will contain the wrong hashes. Reverting the drives means that in the now-canonical fork there is no available room in the queue for all the passengers that queued up in the abandoned fork. This will cause all those txs to revert as well, leading to a bad UX. If the circular buffer is made larger, then the passengers txs can still be re-arranged despite all the `drive` txs reverting. This parameter should be set by estimating the inflow of txs for each chain and multiplying that by the p99 finality window (confirmation time) or another such indicator to minimize the chances that passengers `ride` tx revert under re-orgs. Naturally the queue constrains the `maxNumPassengers`. maxNumPassengers The max number of passengers to drive is an on-chain parameter that limits how many passengers can be driven at once. It is set through the `setMaxNumPassengers` function at wire/configure time but can be later modified. Its purpose is to ensure that all LZ messages are deliverable. Since LZ has a limit on the destination on the message size, we need to ensure on the source that we do not go above that limit. plannerPassengers The number of passengers that the Planner will actually attempt to drive. This is an off-chain parameter that tries to balance cost (by driving as many passengers as possible at once) with speed (by driving as often as possible). It is dynamically set on the off-chain side and the only significance on the contract side is that it corresponds to the typical value the contract will see on calls to `ride`. The way each parameter limits the next one means queueCapacity > maxNumPassengers > plannerPassengers. */ // Represents the bus state. This includes bus identifiers, current seats and a proof to verify the current passengers. struct BusQueue { uint8 maxNumPassengers; // set by the owner uint80 busFare; // set by the planner uint80 busAndNativeDropFare; // set by the planner uint16 qLength; // the length of the queue, i.e. how many passengers are queued up uint72 nextTicketId; // the last ticketId driven + 1, so the next ticketId to be driven mapping(uint16 index => bytes32 hash) hashChain; // hash chain of passengers, range of the index is the bus capacity } struct Bus { uint72 startTicketId; uint8 numPassengers; uint8 totalNativeDrops; bytes passengersBytes; } using BusLib for BusQueue global; /// @title A library containing functionality for riding and driving buses. /// @dev A bus allows sending multiple Stargate `Send`s on a single LZ message, making it very /// @dev cheap. This batching incurs in additional latency, as the messages sent using the bus /// @dev are not immediately sent, but rather stored in the bus until the bus is `drive`n. /// @dev The messages are not actually stored on-chain, but a hash representing them is stored. /// @dev This hash serves as proof that the driver provided the original data when calling /// @dev `drive`. This saves storage. library BusLib { error Bus_InvalidFare(bool nativeDrop); error Bus_InvalidPassenger(); error Bus_QueueFull(); error Bus_InvalidStartTicket(); error Bus_InvalidNumPassengers(uint8 numPassengers); event BusRode(uint32 dstEid, uint72 ticketId, uint80 fare, bytes passenger); event BusDriven(uint32 dstEid, uint72 startTicketId, uint8 numPassengers, bytes32 guid); function setMaxNumPassengers(BusQueue storage _queue, uint8 _maxNumPassengers) internal { _queue.maxNumPassengers = _maxNumPassengers; } function setFares(BusQueue storage _queue, uint80 _busFare, uint80 _busAndNativeDropFare) internal { _queue.busFare = _busFare; _queue.busAndNativeDropFare = _busAndNativeDropFare; } function safeGetFare(BusQueue storage _queue, bool _nativeDrop) internal view returns (uint80 fare) { fare = _nativeDrop ? _queue.busAndNativeDropFare : _queue.busFare; if (fare == 0) revert Bus_InvalidFare(_nativeDrop); } /// @notice Ride the bus, queueing the message for processing. /// @dev Updates the bus structure and emits an event with the relevant data. /// @dev Reverts with BusFull if the bus is full. /// @dev Emits BusRode with the passenger information. function ride( BusQueue storage _queue, uint16 _queueCapacity, uint32 _dstEid, BusPassenger memory _passenger ) internal returns (uint72 ticketId, bytes memory passengerBytes, uint80 fare) { // step 1: generate the ticketId unchecked { // create a new ticket ticketId = _queue.nextTicketId + _queue.qLength++; // check if the bus is full if (_queue.qLength >= _queueCapacity) revert Bus_QueueFull(); } // step 2: generate the passenger bytes passengerBytes = BusCodec.encodePassenger(_passenger); // step 3: calculate the fare fare = _queue.safeGetFare(_passenger.nativeDrop); // step 4: update the hash chain bytes32 lastHash; unchecked { lastHash = ticketId == 0 ? bytes32(0) : _queue.hashChain[uint16((ticketId - 1) % _queueCapacity)]; } _queue.hashChain[uint16(ticketId % _queueCapacity)] = keccak256(abi.encodePacked(lastHash, passengerBytes)); // step 5: emit the event emit BusRode(_dstEid, ticketId, fare, passengerBytes); } /// @notice Drive the bus, validating the payload /// @dev This function validates the payload by re-seating all passengers and also resets the bus state. /// @param _queue The queue to get passengers from /// @param _queueCapacity An immutable value set on TokenMessaging, always larger than the maxNumPassengers /// @param _passengersBytes The concatenated data of all passengers in the bus function checkTicketsAndDrive( BusQueue storage _queue, uint16 _queueCapacity, bytes calldata _passengersBytes ) internal returns (Bus memory bus) { bus = checkTickets(_queue, _queueCapacity, _passengersBytes); // This effectively 'drives' the bus unchecked { _queue.nextTicketId += bus.numPassengers; _queue.qLength -= bus.numPassengers; } } /// @notice Validate that the aggregated payload corresponds to the list of bus passengers. /// @dev Verification is done by re-seating the passengers and recalculating the hash-chain. /// @dev Reverts with InvalidPassenger if the top hashes do not match. function checkTickets( BusQueue storage _queue, uint16 _queueCapacity, bytes calldata _passengersBytes ) internal view returns (Bus memory bus) { // Validate the number of passengers uint8 numPassengers = BusCodec.getNumPassengers(_passengersBytes); if (numPassengers == 0 || numPassengers > _queue.maxNumPassengers || numPassengers > _queue.qLength) { revert Bus_InvalidNumPassengers(numPassengers); } // Generate the last hash uint72 startTicketId = _queue.nextTicketId; bytes32 previousHash = startTicketId == 0 ? bytes32(0) : _queue.hashChain[uint16((startTicketId - 1) % _queueCapacity)]; (uint8 totalNativeDrops, bytes32 lastHash) = BusCodec.parsePassengers(_passengersBytes, previousHash); // Validate the last hash uint72 lastTicketIdToDrive = startTicketId + numPassengers - 1; if (lastHash != _queue.hashChain[uint16(lastTicketIdToDrive % _queueCapacity)]) revert Bus_InvalidPassenger(); // Set the bus params bus.startTicketId = startTicketId; bus.numPassengers = numPassengers; bus.passengersBytes = _passengersBytes; bus.totalNativeDrops = totalNativeDrops; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; struct BusPassenger { uint16 assetId; bytes32 receiver; uint64 amountSD; bool nativeDrop; } /// @title A library for encoding and decoding Bus messages. /// @dev Each bus contains one more more passengers. /// @dev A passenger contains the payload for one transfer. library BusCodec { uint8 internal constant MSG_TYPE_BUS = 2; // Bytes offsets for the passenger payload uint256 internal constant ASSET_ID_OFFSET = 2; uint256 internal constant RECEIVER_OFFSET = 34; uint256 internal constant AMOUNT_SD_OFFSET = 42; uint256 internal constant NATIVE_DROP_OFFSET = 43; uint256 internal constant PASSENGER_BYTES_LENGTH = NATIVE_DROP_OFFSET; // Bytes offsets for the header payload uint256 internal constant MSG_TYPE_BYTES_OFFSET = 1; uint256 internal constant NATIVE_DROP_AMOUNT_TOTAL_OFFSET = 17; uint256 internal constant NATIVE_DROP_AMOUNT_OFFSET = 33; uint256 internal constant HEADER_BYTES_LENGTH = NATIVE_DROP_AMOUNT_OFFSET; error BusCodec_InvalidBusBytesLength(); error BusCodec_InvalidMessage(); error BusCodec_InvalidPassenger(); error BusCodec_InvalidPassengersBytesLength(); // ---------------------------------- Passenger Functions ------------------------------------------ function encodePassenger(BusPassenger memory _passenger) internal pure returns (bytes memory passengerBytes) { passengerBytes = abi.encodePacked( _passenger.assetId, _passenger.receiver, _passenger.amountSD, _passenger.nativeDrop ); } function decodePassenger(bytes calldata _passengerBytes) internal pure returns (BusPassenger memory) { uint16 assetId = uint16(bytes2(_passengerBytes[:ASSET_ID_OFFSET])); bytes32 receiver = bytes32(_passengerBytes[ASSET_ID_OFFSET:RECEIVER_OFFSET]); uint64 amountSD = uint64(bytes8(_passengerBytes[RECEIVER_OFFSET:AMOUNT_SD_OFFSET])); bool nativeDrop = uint8(bytes1(_passengerBytes[AMOUNT_SD_OFFSET:NATIVE_DROP_OFFSET])) == 1; return BusPassenger({ assetId: assetId, receiver: receiver, amountSD: amountSD, nativeDrop: nativeDrop }); } // ---------------------------------- Bus Functions ------------------------------------------ /// @notice Checks if the message is a bus message. function isBus(bytes calldata _message) internal pure returns (bool) { if (_message.length < HEADER_BYTES_LENGTH) revert BusCodec_InvalidMessage(); return uint8(_message[0]) == MSG_TYPE_BUS; } /// @notice Extracts the number of passengers on the bus. function getNumPassengers(bytes calldata _passengersBytes) internal pure returns (uint8) { uint256 passengersBytesLength = _passengersBytes.length; if (passengersBytesLength % PASSENGER_BYTES_LENGTH != 0) revert BusCodec_InvalidPassengersBytesLength(); return SafeCast.toUint8((passengersBytesLength) / PASSENGER_BYTES_LENGTH); } /// @notice Encodes a Bus message. /// @param _numNativeDrops The total number of native drops requested by passengers on the bus. /// @dev Since each passenger can only request whether or not to drop native gas (and not the native drop amount), /// @dev _numNativeDrops <= the number of passengers on the Bus. /// @param _nativeDropAmount The amount destination gas included in the delivery. /// @param _nativeDropAmount is the same for each participating passenger. /// @param _passengersBytes The passengers payload, which contains one or more passengers. /// @return busBytes The encoded Bus message. function encodeBus( uint128 _numNativeDrops, // the number of passengers whom have requested a native drop on the destination uint128 _nativeDropAmount, // amount per drop bytes memory _passengersBytes ) internal pure returns (bytes memory busBytes) { busBytes = abi.encodePacked(MSG_TYPE_BUS, _numNativeDrops, _nativeDropAmount, _passengersBytes); } function decodeBus( bytes calldata _busBytes ) internal pure returns (uint128 totalNativeDrops, uint128 nativeDropAmount, BusPassenger[] memory busPassengers) { // gas savings by loading to memory uint256 busBytesLength = _busBytes.length; // Step 0: check payload length if (busBytesLength < HEADER_BYTES_LENGTH) revert BusCodec_InvalidBusBytesLength(); // Step 1: decode nativeDrop details totalNativeDrops = uint128(bytes16(_busBytes[MSG_TYPE_BYTES_OFFSET:NATIVE_DROP_AMOUNT_TOTAL_OFFSET])); nativeDropAmount = uint128(bytes16(_busBytes[NATIVE_DROP_AMOUNT_TOTAL_OFFSET:NATIVE_DROP_AMOUNT_OFFSET])); // Step 2: determine the number of passengers in the bus. uint256 numPassengers = (busBytesLength - HEADER_BYTES_LENGTH) / PASSENGER_BYTES_LENGTH; // Step 3: Initialize the list of passenger details busPassengers = new BusPassenger[](numPassengers); // Step 4: Set the cursor to the start of the 'busPassengers' uint256 cursor = HEADER_BYTES_LENGTH; // Step 5: Iterate the 'busPassengers' and decode each passenger for (uint8 i = 0; i < numPassengers; i++) { busPassengers[i] = decodePassenger(_busBytes[cursor:cursor + PASSENGER_BYTES_LENGTH]); cursor += PASSENGER_BYTES_LENGTH; } } function parsePassengers( bytes calldata _passengersBytes, bytes32 _previousHash ) internal pure returns (uint8 totalNativeDrops, bytes32 lastHash) { lastHash = _previousHash; // iterate passengers for (uint256 i = 0; i < _passengersBytes.length; i += PASSENGER_BYTES_LENGTH) { // get the current passenger bytes calldata passengerBytes = _passengersBytes[i:i + PASSENGER_BYTES_LENGTH]; // update the lastHash lastHash = keccak256(abi.encodePacked(lastHash, passengerBytes)); // update total native drops bool hasNativeDrop = uint8(passengerBytes[NATIVE_DROP_OFFSET - 1]) == 1; if (hasNativeDrop) totalNativeDrops++; } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { AddressCast } from "./AddressCast.sol"; library TaxiCodec { error TaxiCodec_InvalidMessage(); uint8 internal constant MSG_TYPE_TAXI = 1; uint256 internal constant MSG_TYPE_OFFSET = 1; uint256 internal constant ASSET_ID_OFFSET = 3; uint256 internal constant RECEIVER_OFFSET = 35; uint256 internal constant AMOUNT_SD_OFFSET = 43; function isTaxi(bytes calldata _message) internal pure returns (bool) { if (_message.length < AMOUNT_SD_OFFSET) revert TaxiCodec_InvalidMessage(); return uint8(_message[0]) == MSG_TYPE_TAXI; } function encodeTaxi( address _sender, uint16 _assetId, bytes32 _receiver, uint64 _amountSD, bytes calldata _composeMsg ) internal pure returns (bytes memory _taxiBytes) { _taxiBytes = abi.encodePacked( MSG_TYPE_TAXI, _assetId, _receiver, _amountSD, // @dev Remote chains will want to know the composed function caller ie. msg.sender on the src. _composeMsg.length > 0 ? abi.encodePacked(AddressCast.toBytes32(_sender), _composeMsg) : _composeMsg ); } function decodeTaxi( bytes calldata _taxiBytes ) internal pure returns (uint16 assetId, bytes32 receiver, uint64 amountSD, bytes memory composeMsg) { assetId = uint16(bytes2(_taxiBytes[MSG_TYPE_OFFSET:ASSET_ID_OFFSET])); receiver = bytes32(_taxiBytes[ASSET_ID_OFFSET:RECEIVER_OFFSET]); amountSD = uint64(bytes8(_taxiBytes[RECEIVER_OFFSET:AMOUNT_SD_OFFSET])); composeMsg = _taxiBytes[AMOUNT_SD_OFFSET:]; // This has had the msg.sender encoded into the original composeMsg } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; /// @dev WARNING: Transferring tokens, when the token address is wrong, will fail silently. contract Transfer is Ownable { error Transfer_TransferFailed(); error Transfer_ApproveFailed(); // @dev default this to 2300, but it is modifiable // @dev this is intended to provide just enough gas to receive native tokens. // @dev ie. empty fallbacks or EOA addresses uint256 internal transferGasLimit = 2300; function getTransferGasLimit() external view returns (uint256) { return transferGasLimit; } function setTransferGasLimit(uint256 _gasLimit) external onlyOwner { transferGasLimit = _gasLimit; } /// @notice Transfer native coin to an account /// @dev If gas is unlimited, we pass 63/64 of the gasleft() /// @dev This call may revert due to out of gas instead of returning false. /// @param _to The account to transfer native coin to /// @param _value The amount of native coin to transfer /// @param _gasLimited Whether to limit gas available for the 'fall-back' /// @return success Whether the transfer was successful function transferNative(address _to, uint256 _value, bool _gasLimited) internal returns (bool success) { uint256 gasForCall = _gasLimited ? transferGasLimit : gasleft(); // @dev We dont care about the data returned here, only success or not. assembly { success := call(gasForCall, _to, _value, 0, 0, 0, 0) } } /// @notice Transfer an ERC20 token from the sender to an account /// @param _token The address of the ERC20 token to send /// @param _to The receiving account /// @param _value The amount of tokens to transfer /// @return success Whether the transfer was successful or not function transferToken(address _token, address _to, uint256 _value) internal returns (bool success) { success = _call(_token, abi.encodeWithSelector(IERC20(_token).transfer.selector, _to, _value)); } /// @notice Transfer an ERC20 token from one account to another /// @param _token The address of the ERC20 token to send /// @param _from The source account /// @param _to The destination account /// @param _value The amount of tokens to transfer /// @return success Whether the transfer was successful or not function transferTokenFrom( address _token, address _from, address _to, uint256 _value ) internal returns (bool success) { success = _call(_token, abi.encodeWithSelector(IERC20(_token).transferFrom.selector, _from, _to, _value)); } /// @notice Transfer either native coin or ERC20 token from the sender to an account /// @param _token The ERC20 address or 0x0 if native is desired /// @param _to The destination account /// @param _value the amount to transfer /// @param _gasLimited Whether to limit the amount of gas when doing a native transfer /// @return success Whether the transfer was successful or not function transfer(address _token, address _to, uint256 _value, bool _gasLimited) internal returns (bool success) { if (_token == address(0)) { success = transferNative(_to, _value, _gasLimited); } else { success = transferToken(_token, _to, _value); } } /// @notice Approve a given amount of token for an account /// @param _token The OFT contract to use for approval /// @param _spender The account to approve /// @param _value The amount of tokens to approve /// @return success Whether the approval succeeded function approveToken(address _token, address _spender, uint256 _value) internal returns (bool success) { success = _call(_token, abi.encodeWithSelector(IERC20(_token).approve.selector, _spender, _value)); } /// @notice Transfer native coin to an account or revert /// @dev Reverts with TransferFailed if the transfer failed /// @param _to The account to transfer native coin to /// @param _value The amount of native coin to transfer /// @param _gasLimited Whether to limit the amount of gas to 2300 function safeTransferNative(address _to, uint256 _value, bool _gasLimited) internal { if (!transferNative(_to, _value, _gasLimited)) revert Transfer_TransferFailed(); } /// @notice Transfer an ERC20 token from one account to another or revert /// @dev Reverts with TransferFailed when the transfer fails /// @param _token The address of the ERC20 token to send /// @param _to The destination account /// @param _value The amount of tokens to transfer function safeTransferToken(address _token, address _to, uint256 _value) internal { if (!transferToken(_token, _to, _value)) revert Transfer_TransferFailed(); } /// @notice Transfer an ERC20 token from one account to another /// @dev Reverts with TransferFailed when the transfer fails /// @param _token The address of the ERC20 token to send /// @param _from The source account /// @param _to The destination account /// @param _value The amount of tokens to transfer function safeTransferTokenFrom(address _token, address _from, address _to, uint256 _value) internal { if (!transferTokenFrom(_token, _from, _to, _value)) revert Transfer_TransferFailed(); } /// @notice Transfer either native coin or ERC20 token from the sender to an account /// @dev Reverts with TransferFailed when the transfer fails /// @param _token The ERC20 address or 0x0 if native is desired /// @param _to The destination account /// @param _value the amount to transfer /// @param _gasLimited Whether to limit the amount of gas when doing a native transfer function safeTransfer(address _token, address _to, uint256 _value, bool _gasLimited) internal { if (!transfer(_token, _to, _value, _gasLimited)) revert Transfer_TransferFailed(); } /// @notice Approve a given amount of token for an account or revert /// @dev Reverts with ApproveFailed if the approval failed /// @dev Consider using forceApproveToken(...) to ensure the approval is set correctly. /// @param _token The OFT contract to use for approval /// @param _spender The account to approve /// @param _value The amount of tokens to approve function safeApproveToken(address _token, address _spender, uint256 _value) internal { if (!approveToken(_token, _spender, _value)) revert Transfer_ApproveFailed(); } /// @notice Force approve a given amount of token for an account by first resetting the approval /// @dev Some tokens that require the approval to be set to zero before setting it to a non-zero value, e.g. USDT. /// @param _token The OFT contract to use for approval /// @param _spender The account to approve /// @param _value The amount of tokens to approve function forceApproveToken(address _token, address _spender, uint256 _value) internal { if (!approveToken(_token, _spender, _value)) { safeApproveToken(_token, _spender, 0); safeApproveToken(_token, _spender, _value); } } function _call(address _token, bytes memory _data) private returns (bool success) { // solhint-disable-next-line avoid-low-level-calls (bool s, bytes memory returndata) = _token.call(_data); success = s ? returndata.length == 0 || abi.decode(returndata, (bool)) : false; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { OApp, Origin } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol"; import { OAppPreCrimeSimulator } from "@layerzerolabs/lz-evm-oapp-v2/contracts/precrime/OAppPreCrimeSimulator.sol"; abstract contract MessagingBase is OApp, OAppPreCrimeSimulator { // max asset id, for the off-chain to get the range of asset id and get the list of stargate impls uint16 public maxAssetId; mapping(address stargateImpl => uint16 assetId) public assetIds; mapping(uint16 assetId => address stargateImpl) public stargateImpls; address public planner; event AssetIdSet(address stargateImpl, uint16 assetId); event MaxAssetIdSet(uint16 maxAssetId); event PlannerSet(address planner); error Messaging_Unauthorized(); error Messaging_Unavailable(); error Messaging_InvalidAssetId(); modifier onlyPlanner() { if (msg.sender != planner) revert Messaging_Unauthorized(); _; } constructor(address _endpoint, address _owner) OApp(_endpoint, _owner) {} // ---------------------------------- Only Owner ------------------------------------------ function setAssetId(address _stargateImpl, uint16 _assetId) external onlyOwner { if (_assetId == 0) revert Messaging_InvalidAssetId(); if (_assetId > maxAssetId) { maxAssetId = _assetId; emit MaxAssetIdSet(_assetId); } // clean up the old stargate uint16 oldAssetId = assetIds[_stargateImpl]; address oldStargateImpl = stargateImpls[_assetId]; if (oldAssetId != 0) delete stargateImpls[oldAssetId]; if (oldStargateImpl != address(0)) delete assetIds[oldStargateImpl]; // if stargateImpl is address(0) then delete stargateImpls[_assetId] if (_stargateImpl == address(0)) { delete stargateImpls[_assetId]; } else { // set the new stargate assetIds[_stargateImpl] = _assetId; stargateImpls[_assetId] = _stargateImpl; } emit AssetIdSet(_stargateImpl, _assetId); } /// @dev Update the max asset id manually if it is not set correctly function setMaxAssetId(uint16 _maxAssetId) external onlyOwner { maxAssetId = _maxAssetId; emit MaxAssetIdSet(_maxAssetId); } function setPlanner(address _planner) external onlyOwner { planner = _planner; emit PlannerSet(_planner); } // ---------------------------------- Internal Functions ------------------------------------------ function _safeGetStargateImpl(uint16 _assetId) internal view returns (address stargate) { stargate = stargateImpls[_assetId]; if (stargate == address(0)) revert Messaging_Unavailable(); } function _safeGetAssetId(address _stargateImpl) internal view returns (uint16 assetId) { assetId = assetIds[_stargateImpl]; if (assetId == 0) revert Messaging_Unavailable(); } /// @dev Lz token is payed in the stargate contract and do nothing here. /// Function meant to be overridden // solhint-disable-next-line no-empty-blocks function _payLzToken(uint256 /*_lzTokenFee*/) internal pure override {} // ---------------------------------- PreCrime Functions ------------------------------------------ function _lzReceiveSimulate( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) internal override { _lzReceive(_origin, _guid, _message, _executor, _extraData); } function isPeer(uint32 _eid, bytes32 _peer) public view override returns (bool) { return _peer == peers[_eid]; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import { OAppOptionsType3 } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/libs/OAppOptionsType3.sol"; struct GasLimit { uint128 gasLimit; uint128 nativeDropGasLimit; } contract TokenMessagingOptions is OAppOptionsType3 { uint8 public constant MSG_TYPE_TAXI = 1; uint8 public constant MSG_TYPE_BUS = 2; uint8 internal constant EXECUTOR_WORKER_ID = 1; uint8 internal constant OPTION_TYPE_LZRECEIVE = 1; uint16 internal constant OPTION_LZRECEIVE_BASE_PARAMS_SIZE = 17; // type(1) + gas(16) uint16 internal constant OPTION_LZRECEIVE_PARAMS_SIZE = 33; // type(1) + gas(16) + value(16) uint256 internal constant PASSENGER_SIZE = 43; mapping(uint32 eid => GasLimit gasLimit) public gasLimits; event GasLimitSet(uint32 eid, uint128 gasLimit, uint128 nativeDropGasLimit); error MessagingOptions_ZeroGasLimit(); function setGasLimit(uint32 _eid, uint128 _gasLimit, uint128 _nativeDropGasLimit) external onlyOwner { gasLimits[_eid] = GasLimit(_gasLimit, _nativeDropGasLimit); emit GasLimitSet(_eid, _gasLimit, _nativeDropGasLimit); } function _buildOptionsForTaxi( uint32 _eid, bytes calldata _extraOptions ) internal view returns (bytes memory options) { options = combineOptions(_eid, MSG_TYPE_TAXI, _extraOptions); } function _buildOptionsForDriveBus( uint32 _eid, uint8 _numPassengers, uint256 _totalNativeDrops, uint128 _nativeDropAmount ) internal view returns (bytes memory options) { // determine the gasLimit for delivering N passengers (uint128 gasLimit, uint128 nativeDropGasLimit) = _safeGetGasLimit(_eid); uint128 totalGas = SafeCast.toUint128(uint256(gasLimit) * _numPassengers); // calculate the total amount of native to drop uint128 totalNativeDropAmount = SafeCast.toUint128(_totalNativeDrops * _nativeDropAmount); // append the extraGas that is needed to distribute the _nativeDropAmount amongst the passengers with a drop if (totalNativeDropAmount > 0) totalGas += SafeCast.toUint128(nativeDropGasLimit * _totalNativeDrops); // generate the lzReceive options bytes memory lzReceiveOptions = totalNativeDropAmount > 0 ? abi.encodePacked( EXECUTOR_WORKER_ID, OPTION_LZRECEIVE_PARAMS_SIZE, OPTION_TYPE_LZRECEIVE, totalGas, totalNativeDropAmount ) : abi.encodePacked(EXECUTOR_WORKER_ID, OPTION_LZRECEIVE_BASE_PARAMS_SIZE, OPTION_TYPE_LZRECEIVE, totalGas); // if enforced options are present, concat them bytes memory enforced = enforcedOptions[_eid][MSG_TYPE_BUS]; if (enforced.length >= 2) { options = abi.encodePacked(enforced, lzReceiveOptions); } else { options = abi.encodePacked(OPTION_TYPE_3, lzReceiveOptions); } } function _safeGetGasLimit(uint32 _eid) private view returns (uint128 gasLimit, uint128 nativeDropGasLimit) { GasLimit memory g = gasLimits[_eid]; gasLimit = g.gasLimit; nativeDropGasLimit = g.nativeDropGasLimit; // dont require setting nativeDropGasLimit if (gasLimit == 0) revert MessagingOptions_ZeroGasLimit(); } }
{ "evmVersion": "paris", "optimizer": { "enabled": true, "runs": 5000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_endpoint","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint16","name":"_queueCapacity","type":"uint16"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BusCodec_InvalidBusBytesLength","type":"error"},{"inputs":[],"name":"BusCodec_InvalidMessage","type":"error"},{"inputs":[],"name":"BusCodec_InvalidPassengersBytesLength","type":"error"},{"inputs":[{"internalType":"bool","name":"nativeDrop","type":"bool"}],"name":"Bus_InvalidFare","type":"error"},{"inputs":[{"internalType":"uint8","name":"numPassengers","type":"uint8"}],"name":"Bus_InvalidNumPassengers","type":"error"},{"inputs":[],"name":"Bus_InvalidPassenger","type":"error"},{"inputs":[],"name":"Bus_QueueFull","type":"error"},{"inputs":[],"name":"InvalidDelegate","type":"error"},{"inputs":[],"name":"InvalidEndpointCall","type":"error"},{"inputs":[{"internalType":"bytes","name":"options","type":"bytes"}],"name":"InvalidOptions","type":"error"},{"inputs":[],"name":"LzTokenUnavailable","type":"error"},{"inputs":[],"name":"MessagingOptions_ZeroGasLimit","type":"error"},{"inputs":[],"name":"Messaging_InvalidAssetId","type":"error"},{"inputs":[],"name":"Messaging_InvalidEid","type":"error"},{"inputs":[],"name":"Messaging_InvalidMsgValue","type":"error"},{"inputs":[],"name":"Messaging_InvalidQueueCapacity","type":"error"},{"inputs":[],"name":"Messaging_MaxNumPassengersExceedsQueueCapacity","type":"error"},{"inputs":[],"name":"Messaging_NotEnoughPassengers","type":"error"},{"inputs":[],"name":"Messaging_Unauthorized","type":"error"},{"inputs":[],"name":"Messaging_Unavailable","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":"bytes","name":"result","type":"bytes"}],"name":"SimulationResult","type":"error"},{"inputs":[],"name":"TaxiCodec_InvalidMessage","type":"error"},{"inputs":[],"name":"Transfer_ApproveFailed","type":"error"},{"inputs":[],"name":"Transfer_TransferFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stargateImpl","type":"address"},{"indexed":false,"internalType":"uint16","name":"assetId","type":"uint16"}],"name":"AssetIdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":false,"internalType":"uint72","name":"startTicketId","type":"uint72"},{"indexed":false,"internalType":"uint8","name":"numPassengers","type":"uint8"},{"indexed":false,"internalType":"bytes32","name":"guid","type":"bytes32"}],"name":"BusDriven","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":false,"internalType":"uint16","name":"startSlot","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"endSlot","type":"uint16"}],"name":"BusQueueStorageInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":false,"internalType":"uint72","name":"ticketId","type":"uint72"},{"indexed":false,"internalType":"uint80","name":"fare","type":"uint80"},{"indexed":false,"internalType":"bytes","name":"passenger","type":"bytes"}],"name":"BusRode","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":"uint32","name":"dstEid","type":"uint32"},{"indexed":false,"internalType":"uint80","name":"busFare","type":"uint80"},{"indexed":false,"internalType":"uint80","name":"busAndNativeDropFare","type":"uint80"}],"name":"FaresSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"eid","type":"uint32"},{"indexed":false,"internalType":"uint128","name":"gasLimit","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"nativeDropGasLimit","type":"uint128"}],"name":"GasLimitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"maxAssetId","type":"uint16"}],"name":"MaxAssetIdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":false,"internalType":"uint8","name":"maxNumPassengers","type":"uint8"}],"name":"MaxNumPassengersSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":false,"internalType":"uint128","name":"nativeDropAmount","type":"uint128"}],"name":"NativeDropAmountSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"NativeDropApplied","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"NativeDropFailed","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":"planner","type":"address"}],"name":"PlannerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"preCrimeAddress","type":"address"}],"name":"PreCrimeSet","type":"event"},{"inputs":[],"name":"MSG_TYPE_BUS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MSG_TYPE_TAXI","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"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":"stargateImpl","type":"address"}],"name":"assetIds","outputs":[{"internalType":"uint16","name":"assetId","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"dstEid","type":"uint32"}],"name":"busQueues","outputs":[{"internalType":"uint8","name":"maxNumPassengers","type":"uint8"},{"internalType":"uint80","name":"busFare","type":"uint80"},{"internalType":"uint80","name":"busAndNativeDropFare","type":"uint80"},{"internalType":"uint16","name":"qLength","type":"uint16"},{"internalType":"uint72","name":"nextTicketId","type":"uint72"}],"stateMutability":"view","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":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"bytes","name":"_passengers","type":"bytes"}],"name":"driveBus","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":"receipt","type":"tuple"}],"stateMutability":"payable","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":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"gasLimits","outputs":[{"internalType":"uint128","name":"gasLimit","type":"uint128"},{"internalType":"uint128","name":"nativeDropGasLimit","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getPassengerHash","outputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTransferGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_dstEids","type":"uint32[]"},{"internalType":"uint16","name":"_startSlot","type":"uint16"},{"internalType":"uint16","name":"_endSlot","type":"uint16"}],"name":"initializeBusQueueStorage","outputs":[],"stateMutability":"nonpayable","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":"_message","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":[{"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":"maxAssetId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"dstEid","type":"uint32"}],"name":"nativeDropAmounts","outputs":[{"internalType":"uint128","name":"nativeDropAmount","type":"uint128"}],"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":[],"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":"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":[],"name":"planner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"preCrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"queueCapacity","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"bytes","name":"_passengers","type":"bytes"}],"name":"quoteDriveBus","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"uint8","name":"_numPassengers","type":"uint8"}],"name":"quoteFares","outputs":[{"internalType":"uint256","name":"busFare","type":"uint256"},{"internalType":"uint256","name":"busAndNativeDropFare","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"bool","name":"_airdrop","type":"bool"}],"name":"quoteRideBus","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"uint64","name":"amountSD","type":"uint64"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"extraOptions","type":"bytes"}],"internalType":"struct TaxiParams","name":"_params","type":"tuple"},{"internalType":"bool","name":"_payInLzToken","type":"bool"}],"name":"quoteTaxi","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"uint64","name":"amountSD","type":"uint64"},{"internalType":"bool","name":"nativeDrop","type":"bool"}],"internalType":"struct RideBusParams","name":"_params","type":"tuple"}],"name":"rideBus","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":"receipt","type":"tuple"},{"components":[{"internalType":"uint72","name":"ticketId","type":"uint72"},{"internalType":"bytes","name":"passengerBytes","type":"bytes"}],"internalType":"struct Ticket","name":"ticket","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stargateImpl","type":"address"},{"internalType":"uint16","name":"_assetId","type":"uint16"}],"name":"setAssetId","outputs":[],"stateMutability":"nonpayable","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":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"uint80","name":"_busFare","type":"uint80"},{"internalType":"uint80","name":"_busAndNativeDropFare","type":"uint80"}],"name":"setFares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"uint128","name":"_gasLimit","type":"uint128"},{"internalType":"uint128","name":"_nativeDropGasLimit","type":"uint128"}],"name":"setGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxAssetId","type":"uint16"}],"name":"setMaxAssetId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"uint8","name":"_maxNumPassengers","type":"uint8"}],"name":"setMaxNumPassengers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"uint128","name":"_nativeDropAmount","type":"uint128"}],"name":"setNativeDropAmount","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":"_planner","type":"address"}],"name":"setPlanner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_preCrime","type":"address"}],"name":"setPreCrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"setTransferGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"assetId","type":"uint16"}],"name":"stargateImpls","outputs":[{"internalType":"address","name":"stargateImpl","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"uint64","name":"amountSD","type":"uint64"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"extraOptions","type":"bytes"}],"internalType":"struct TaxiParams","name":"_params","type":"tuple"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"_messagingFee","type":"tuple"},{"internalType":"address","name":"_refundAddress","type":"address"}],"name":"taxi","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":"receipt","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60e06040526108fc6001553480156200001757600080fd5b506040516200558d3803806200558d8339810160408190526200003a91620001fe565b8282818181816200004b3362000191565b6001600160a01b0380831660805281166200007957604051632d618d8160e21b815260040160405180910390fd5b60805160405163ca5eb5e160e01b81526001600160a01b0383811660048301529091169063ca5eb5e190602401600060405180830381600087803b158015620000c157600080fd5b505af1158015620000d6573d6000803e3d6000fd5b5050505050505050505060028161ffff16101562000107576040516327f53ac760e01b815260040160405180910390fd5b8061ffff1660a08161ffff16815250506080516001600160a01b031663416ecebf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000158573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200017e919062000252565b63ffffffff1660c0525062000281915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620001f957600080fd5b919050565b6000806000606084860312156200021457600080fd5b6200021f84620001e1565b92506200022f60208501620001e1565b9150604084015161ffff811681146200024757600080fd5b809150509250925092565b6000602082840312156200026557600080fd5b815163ffffffff811681146200027a57600080fd5b9392505050565b60805160a05160c05161528f620002fe6000396000610d5001526000818161087401528181610bc301528181610e3d0152818161104d0152818161146401528181611da901528181611ea60152611ee60152600081816104f101528181610c1a01528181611bb1015281816124500152612871015261528f6000f3fe60806040526004361061031e5760003560e01c806385afd453116101a5578063c239f1ad116100ec578063ee5ccf6a11610095578063fd6f05571161006f578063fd6f055714610af5578063fdee84ec14610b15578063ff6fb30014610b5d578063ff7bd03d14610b7057600080fd5b8063ee5ccf6a14610a35578063f2fde38b14610a55578063f8d50da614610a7557600080fd5b8063d4243885116100c6578063d4243885146109c4578063d8e8dbc7146109e4578063e4c572cc14610a1557600080fd5b8063c239f1ad1461097c578063ca5eb5e114610991578063d045a0dc146109b157600080fd5b8063917df23b1161014e578063bb0b6a5311610128578063bb0b6a531461091c578063bc70b35414610949578063bd815db01461096957600080fd5b8063917df23b146108a9578063b731ea0a146108dc578063b98bd070146108fc57600080fd5b80638da5cb5b1161017f5780638da5cb5b146108245780638f71f7dd1461084257806390fdb20c1461086257600080fd5b806385afd453146107b757806388543f0e146107e55780638c70830b1461080457600080fd5b80635e280f1111610269578063731dbe0c116102125780637d25a05e116101ec5780637d25a05e1461073b57806382413eac14610777578063826f1fb11461079757600080fd5b8063731dbe0c1461068657806375d2208c146106e65780637845ca231461070657600080fd5b80636763d689116102435780636763d689146105695780636ad9914d14610589578063715018a61461067157600080fd5b80635e280f11146104df5780635f6d9ae41461051357806364e4ac271461054957600080fd5b806332e4e363116102cb57806352ae2879116102a557806352ae28791461046f5780635535d461146104825780635a0dfe4d146104af57600080fd5b806332e4e363146103f05780633400288b1461042857806345655a161461044857600080fd5b80632b28b34e116102fc5780632b28b34e146103905780632dca2f51146103b05780633292cf02146103d057600080fd5b8063086431ec1461032357806313137d651461035957806317442b701461036e575b600080fd5b34801561032f57600080fd5b5061034361033e366004613d85565b610b90565b6040516103509190613dd8565b60405180910390f35b61036c610367366004613e1e565b610c18565b005b34801561037a57600080fd5b5060408051600181526002602082015201610350565b34801561039c57600080fd5b5061036c6103ab366004613ed7565b610d0a565b3480156103bc57600080fd5b5061036c6103cb366004613f1a565b610e33565b3480156103dc57600080fd5b506103436103eb366004613f79565b610f03565b3480156103fc57600080fd5b50600654610410906001600160a01b031681565b6040516001600160a01b039091168152602001610350565b34801561043457600080fd5b5061036c610443366004613fc7565b610f4c565b34801561045457600080fd5b5061045d600181565b60405160ff9091168152602001610350565b34801561047b57600080fd5b5030610410565b34801561048e57600080fd5b506104a261049d366004614003565b610f62565b604051610350919061407d565b3480156104bb57600080fd5b506104cf6104ca366004613fc7565b611007565b6040519015158152602001610350565b3480156104eb57600080fd5b506104107f000000000000000000000000000000000000000000000000000000000000000081565b34801561051f57600080fd5b5061041061052e366004614097565b6005602052600090815260409020546001600160a01b031681565b61055c610557366004613d85565b611026565b60405161035091906140e6565b34801561057557600080fd5b5061036c610584366004614114565b61111e565b34801561059557600080fd5b506106266105a436600461413e565b60096020526000908152604090205460ff81169069ffffffffffffffffffff61010082048116916b01000000000000000000000081049091169061ffff75010000000000000000000000000000000000000000008204169068ffffffffffffffffff770100000000000000000000000000000000000000000000009091041685565b6040805160ff96909616865269ffffffffffffffffffff9485166020870152929093169184019190915261ffff16606083015268ffffffffffffffffff16608082015260a001610350565b34801561067d57600080fd5b5061036c6111ad565b34801561069257600080fd5b506106c56106a136600461413e565b600a602052600090815260409020546fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff9091168152602001610350565b3480156106f257600080fd5b50610343610701366004614159565b6111c1565b34801561071257600080fd5b50610726610721366004613f1a565b61120b565b60408051928352602083019190915201610350565b34801561074757600080fd5b5061075e610756366004613fc7565b600092915050565b60405167ffffffffffffffff9091168152602001610350565b34801561078357600080fd5b506104cf610792366004614183565b611346565b3480156107a357600080fd5b5061036c6107b23660046141e9565b6113a7565b3480156107c357600080fd5b506107d76107d2366004614204565b61141c565b604051610350929190614216565b3480156107f157600080fd5b506001545b604051908152602001610350565b34801561081057600080fd5b5061036c61081f366004614254565b61153b565b34801561083057600080fd5b506000546001600160a01b0316610410565b34801561084e57600080fd5b5061036c61085d36600461426d565b611548565b34801561086e57600080fd5b506108967f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff9091168152602001610350565b3480156108b557600080fd5b506003546108969074010000000000000000000000000000000000000000900461ffff1681565b3480156108e857600080fd5b50600354610410906001600160a01b031681565b34801561090857600080fd5b5061036c6109173660046142ce565b61180a565b34801561092857600080fd5b506107f661093736600461413e565b60026020526000908152604090205481565b34801561095557600080fd5b506104a2610964366004614310565b611824565b61036c6109773660046142ce565b6119e5565b34801561098857600080fd5b5061045d600281565b34801561099d57600080fd5b5061036c6109ac3660046141e9565b611b71565b61036c6109bf366004613e1e565b611c10565b3480156109d057600080fd5b5061036c6109df3660046141e9565b611c58565b3480156109f057600080fd5b506108966109ff3660046141e9565b60046020526000908152604090205461ffff1681565b348015610a2157600080fd5b5061036c610a30366004614097565b611cc6565b348015610a4157600080fd5b5061036c610a50366004614371565b611d49565b348015610a6157600080fd5b5061036c610a703660046141e9565b611fe7565b348015610a8157600080fd5b50610acc610a9036600461413e565b6008602052600090815260409020546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b604080516fffffffffffffffffffffffffffffffff938416815292909116602083015201610350565b348015610b0157600080fd5b5061036c610b103660046143cb565b612091565b348015610b2157600080fd5b506107f6610b30366004614003565b63ffffffff909116600090815260096020908152604080832061ffff909416835260019093019052205490565b61055c610b6b366004614405565b61212f565b348015610b7c57600080fd5b506104cf610b8b366004614466565b61217c565b604080518082019091526000808252602082015263ffffffff80851660009081526009602052604081209091610bed91907f000000000000000000000000000000000000000000000000000000000000000090879087906121b216565b9050600080610bfc87846123cd565b91509150610c0d878383600061243a565b979650505050505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163314610c81576040517f91ac5e4f0000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b60208701803590610c9b90610c96908a61413e565b612512565b14610cf257610cad602088018861413e565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff909116600482015260208801356024820152604401610c78565b610d0187878787878787612567565b50505050505050565b6006546001600160a01b03163314610d4e576040517fc63aab2c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff168363ffffffff1603610db3576040517fa27dd10200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff8084166000908152600960205260409020610dd7918490849061259316565b6040805163ffffffff8516815269ffffffffffffffffffff80851660208301528316918101919091527fd2245824774f1c2de21256e9fb34d9cc4633cf72c0952a82a996e45ad4df3c70906060015b60405180910390a1505050565b610e3b612603565b7f000000000000000000000000000000000000000000000000000000000000000061ffff168160ff1610610e9b576040517f31843b5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff8083166000908152600960205260409020610ebd91839061267716565b6040805163ffffffff8416815260ff831660208201527ff9fa6c3c4dbf13c4a8348c3102ef22789aa450b81e492b853e93f9701e08958091015b60405180910390a15050565b6040805180820190915260008082526020820152600080610f23856126a6565b9092509050610f43610f3b604087016020880161413e565b83838761243a565b95945050505050565b610f54612603565b610f5e828261271d565b5050565b600760209081526000928352604080842090915290825290208054610f8690614482565b80601f0160208091040260200160405190810160405280929190818152602001828054610fb290614482565b8015610fff5780601f10610fd457610100808354040283529160200191610fff565b820191906000526020600020905b815481529060010190602001808311610fe257829003601f168201915b505050505081565b63ffffffff821660009081526002602052604090205481145b92915050565b61102e613ce0565b63ffffffff8085166000908152600960205260408120909161107791907f0000000000000000000000000000000000000000000000000000000000000000908790879061276b16565b905060008061108687846123cd565b915091506110ac8783836040518060400160405280348152602001600081525033612865565b835160208086015183516040805163ffffffff8e16815268ffffffffffffffffff9095169385019390935260ff909116838301526060830152519195507f1623f9ea59bd6f214c9571a892da012fc23534aa5906bef4ae8c5d15ee7d2d6e919081900360800190a15050509392505050565b611126612603565b63ffffffff82166000818152600a602090815260409182902080547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff86169081179091558251938452908301527f5b9fac6cf74b12ad67aa143075523ab25ca781b0f611c4897b31d1500f2ae9629101610ef7565b6111b5612603565b6111bf600061293e565b565b604080518082019091526000808252602082015263ffffffff80841660009081526009602052604090206111f79184906129a616565b69ffffffffffffffffffff16815292915050565b6000808260ff1660000361124b576040517fe3a9395200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061125b602b60ff86166144fe565b67ffffffffffffffff81111561127357611273614515565b6040519080825280601f01601f19166020018201604052801561129d576020820181803683370190505b50905060006112ae60008084612a2f565b905060006112bf8787600080612a61565b90508560ff166112d2888484600061243a565b516112dd9190614573565b63ffffffff88166000908152600a60205260408120549196509061131b908990899060ff8216906fffffffffffffffffffffffffffffffff16612a61565b90508660ff1661132e898584600061243a565b516113399190614573565b9450505050509250929050565b60006113528484612d6e565b1561139b5760006113638585612dd2565b50505061ffff81166000908152600560205260409020549091506001600160a01b0380851691160361139957600191505061139f565b505b5060005b949350505050565b6113af612603565b600680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f5767d79cd17d7554509a4dd59a5a7a9175c7e36466455d7b2fa4788228808579906020015b60405180910390a150565b611424613ce0565b604080518082019091526000815260606020820152600061144433612e77565b90506000611458604086016020870161413e565b905060008060006114f97f00000000000000000000000000000000000000000000000000000000000000008560405180608001604052808961ffff1681526020018c6040013581526020018c60600160208101906114b6919061459d565b67ffffffffffffffff1681526020016114d560a08e0160808f016145ba565b1515905263ffffffff808916600090815260096020526040902093929190612ed316565b60408051808201825268ffffffffffffffffff909416845260208401929092529089015169ffffffffffffffffffff9190911690529698969750505050505050565b611543612603565b600155565b611550612603565b8061ffff1660000361158e576040517fe447547600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035461ffff740100000000000000000000000000000000000000009091048116908216111561163757600380547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c0179060200160405180910390a15b6001600160a01b0380831660009081526004602090815260408083205461ffff868116855260059093529220549116911681156116a85761ffff8216600090815260056020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b6001600160a01b038116156116f6576001600160a01b038116600090815260046020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001690555b6001600160a01b0384166117425761ffff8316600090815260056020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556117bf565b6001600160a01b038416600081815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff891690811790915583526005909152902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690911790555b604080516001600160a01b038616815261ffff851660208201527fac53470cf8e9e3d673caa7d47cd7db36c0d38cf37fc147c70c92bc0c1c4734f5910160405180910390a150505050565b611812612603565b610f5e61181f828461467a565b6130b8565b63ffffffff8416600090815260076020908152604080832061ffff8716845290915281208054606092919061185890614482565b80601f016020809104026020016040519081016040528092919081815260200182805461188490614482565b80156118d15780601f106118a6576101008083540402835291602001916118d1565b820191906000526020600020905b8154815290600101906020018083116118b457829003601f168201915b5050505050905080516000036119215783838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092945061139f9350505050565b600083900361193157905061139f565b600283106119af5761197884848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506131bf92505050565b806119868460028188614790565b604051602001611998939291906147ba565b60405160208183030381529060405291505061139f565b83836040517f9a6d49cd000000000000000000000000000000000000000000000000000000008152600401610c7892919061480d565b60005b81811015611ad75736838383818110611a0357611a03614821565b9050602002810190611a159190614850565b9050611a31611a27602083018361413e565b6020830135611007565b611a3b5750611acf565b3063d045a0dc60c08301358360a0810135611a5a61010083018361488e565b611a6b610100890160e08a016141e9565b611a796101208a018a61488e565b6040518963ffffffff1660e01b8152600401611a9b9796959493929190614931565b6000604051808303818588803b158015611ab457600080fd5b505af1158015611ac8573d6000803e3d6000fd5b5050505050505b6001016119e8565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611b16573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b3e9190810190614988565b6040517f8351eea7000000000000000000000000000000000000000000000000000000008152600401610c78919061407d565b611b79612603565b6040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063ca5eb5e190602401600060405180830381600087803b158015611bf557600080fd5b505af1158015611c09573d6000803e3d6000fd5b5050505050565b333014611c49576040517f14d4a4e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d0187878787878787610cf2565b611c60612603565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c242776090602001611411565b611cce612603565b600380547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c01790602001611411565b611d51612603565b60005b83811015611c0957600060096000878785818110611d7457611d74614821565b9050602002016020810190611d89919061413e565b63ffffffff1681526020810191909152604001600020805490915061ffff7f0000000000000000000000000000000000000000000000000000000000000000811691611e169175010000000000000000000000000000000000000000008204169068ffffffffffffffffff77010000000000000000000000000000000000000000000000909104166149f6565b68ffffffffffffffffff161115611e2d5750611fdf565b8054600090611e7f907501000000000000000000000000000000000000000000810461ffff169077010000000000000000000000000000000000000000000000900468ffffffffffffffffff166149f6565b905060008161ffff168661ffff161015611e995781611e9b565b855b90506000611eca60017f0000000000000000000000000000000000000000000000000000000000000000614a1f565b61ffff168661ffff161015611edf5785611f0a565b611f0a60017f0000000000000000000000000000000000000000000000000000000000000000614a1f565b9050815b8161ffff168161ffff1611611f675761ffff8116600090815260018601602052604090207f4600000000000000000000000000000000000000000000000000000000000000905580611f5f81614a3a565b915050611f0e565b507f68ae5a72b18bd3a6fbbc56d3cddb8a1c567b1d6ad4e705dd0b9295de05262bf4898987818110611f9b57611f9b614821565b9050602002016020810190611fb0919061413e565b6040805163ffffffff909216825261ffff808616602084015284169082015260600160405180910390a1505050505b600101611d54565b611fef612603565b6001600160a01b038116612085576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610c78565b61208e8161293e565b50565b612099612603565b6040805180820182526fffffffffffffffffffffffffffffffff848116808352848216602080850182815263ffffffff8a16600081815260088452889020965191518616700100000000000000000000000000000000029190951617909455845192835292820152918201527fff958b7fbea293188b750425e92bd9c7a646f9063b9fc7722ae861802a7a1fe790606001610e26565b612137613ce0565b600080612143866126a6565b909250905061217261215b604088016020890161413e565b838361216c368a90038a018a614a5b565b88612865565b9695505050505050565b6000602082018035906002908390612194908661413e565b63ffffffff1681526020810191909152604001600020541492915050565b60408051608081018252600080825260208201819052918101829052606080820152906121df8484613204565b905060ff811615806121f85750855460ff908116908216115b80612223575085547501000000000000000000000000000000000000000000900461ffff1660ff8216115b1561225f576040517fc5ad74c700000000000000000000000000000000000000000000000000000000815260ff82166004820152602401610c78565b855477010000000000000000000000000000000000000000000000900468ffffffffffffffffff16600081156122cd578760010160008861ffff166001856122a79190614a8d565b6122b19190614aaf565b61ffff1661ffff168152602001908152602001600020546122d0565b60005b90506000806122e088888561325c565b9092509050600060016122f660ff8816876149f6565b6123009190614a8d565b905060018b01600061231661ffff8d1684614aaf565b61ffff1661ffff168152602001908152602001600020548214612365576040517f5b3f67cd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b68ffffffffffffffffff8516875260ff861660208089019190915260408051601f8b01839004830281018301909152898152908a908a90819084018382808284376000920191909152505050506060880152505060ff16604085015250919695505050505050565b63ffffffff82166000908152600a6020526040908190205490820151606083810151909283926fffffffffffffffffffffffffffffffff909116916124179160ff16908390612a2f565b9250612430858560200151866040015160ff1684612a61565b9150509250929050565b60408051808201909152600080825260208201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ddc28c586040518060a001604052808863ffffffff16815260200161249d89612512565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b81526004016124d2929190614ad7565b6040805180830381865afa1580156124ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f439190614b9e565b63ffffffff811660009081526002602052604081205480611020576040517ff6ff4fb700000000000000000000000000000000000000000000000000000000815263ffffffff84166004820152602401610c78565b612571858561331a565b15612587576125828787878761336a565b610d01565b610d01878787876135ea565b82547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1661010069ffffffffffffffffffff938416027fffffffffffffffffffffff00000000000000000000ffffffffffffffffffffff16176b0100000000000000000000009190921602179055565b6000546001600160a01b031633146111bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c78565b81547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff91909116179055565b60608060006126b433612e77565b90506126ee6126c660208601866141e9565b8260408701356126dc6080890160608a0161459d565b6126e960808a018a61488e565b6136a6565b9250612715612703604086016020870161413e565b61271060a087018761488e565b61374b565b915050915091565b63ffffffff8216600081815260026020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b9101610ef7565b604080516080810182526000808252602082018190529181019190915260608082015261279a858585856121b2565b6020810151865460ff90911661ffff750100000000000000000000000000000000000000000068ffffffffffffffffff77010000000000000000000000000000000000000000000000808604821685019091160276ffffffffffffffffffffffffffffffffffffffffffffff85168117829004831693909303909116027fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff90911674ffffffffffffffffffffffffffffffffffffffffff909216919091171790955550929392505050565b61286d613ce0565b82517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632637a450826040518060a001604052808b63ffffffff1681526020016128bf8c612512565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b81526004016128fb929190614ad7565b60806040518083038185885af1158015612919573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c0d9190614bba565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000816129c5578254610100900469ffffffffffffffffffff166129e3565b82546b010000000000000000000000900469ffffffffffffffffffff165b90508069ffffffffffffffffffff16600003611020576040517f5bc181900000000000000000000000000000000000000000000000000000000081528215156004820152602401610c78565b60606002848484604051602001612a499493929190614c04565b60405160208183030381529060405290509392505050565b6060600080612a6f8761375a565b90925090506000612a9d612a9860ff89166fffffffffffffffffffffffffffffffff86166144fe565b6137ee565b90506000612ac0612a986fffffffffffffffffffffffffffffffff8816896144fe565b90506fffffffffffffffffffffffffffffffff811615612b0657612af9612a98886fffffffffffffffffffffffffffffffff86166144fe565b612b039083614c89565b91505b600080826fffffffffffffffffffffffffffffffff1611612bb9576040517f0100000000000000000000000000000000000000000000000000000000000000602082018190527e11000000000000000000000000000000000000000000000000000000000000602183015260238201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608085901b166024820152603401604051602081830303815290604052612c57565b6040517f0100000000000000000000000000000000000000000000000000000000000000602082018190527e21000000000000000000000000000000000000000000000000000000000000602183015260238201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608085811b8216602484015284901b1660348201526044016040516020818303038152906040525b63ffffffff8b16600090815260076020908152604080832060028452909152812080549293509091612c8890614482565b80601f0160208091040260200160405190810160405280929190818152602001828054612cb490614482565b8015612d015780601f10612cd657610100808354040283529160200191612d01565b820191906000526020600020905b815481529060010190602001808311612ce457829003601f168201915b505050505090506002815110612d3a578082604051602001612d24929190614cb2565b6040516020818303038152906040529650612d60565b600382604051602001612d4e929190614ce1565b60405160208183030381529060405296505b505050505050949350505050565b6000602b821015612dab576040517fde01ff2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018383600081612dbe57612dbe614821565b919091013560f81c91909114949350505050565b600080806060612de6600360018789614790565b612def91614d2c565b60f01c9350612e02602360038789614790565b612e0b91614d74565b9250612e1b602b60238789614790565b612e2491614d92565b60c01c9150612e3685602b8189614790565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509699959850939650909450505050565b6001600160a01b03811660009081526004602052604081205461ffff1690819003612ece576040517f8b6fecb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b8354600161ffff75010000000000000000000000000000000000000000008084048216928301821681027fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff9094169390931780885568ffffffffffffffffff7701000000000000000000000000000000000000000000000082041690920192606092600092888116929091041610612f97576040517ffa36e2ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612fa084613894565b9150612fb98460600151886129a690919063ffffffff16565b9050600068ffffffffffffffffff841615613012578760010160008861ffff166001870368ffffffffffffffffff1681612ff557612ff5614544565b0661ffff1661ffff16815260200190815260200160002054613015565b60005b9050808360405160200161302a929190614dd8565b604051602081830303815290604052805190602001208860010160008961ffff16876130569190614aaf565b61ffff1661ffff168152602001908152602001600020819055507f15955c5a4cc61b8fbb05301bce47fd31c0e6f935e1ab97fdac9b134c887bb074868584866040516130a59493929190614dfe565b60405180910390a1509450945094915050565b60005b815181101561318f576130ea8282815181106130d9576130d9614821565b6020026020010151604001516131bf565b8181815181106130fc576130fc614821565b6020026020010151604001516007600084848151811061311e5761311e614821565b60200260200101516000015163ffffffff1663ffffffff168152602001908152602001600020600084848151811061315857613158614821565b60200260200101516020015161ffff1661ffff16815260200190815260200160002090816131869190614e90565b506001016130bb565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b674816040516114119190614f50565b600281015161ffff8116600314610f5e57816040517f9a6d49cd000000000000000000000000000000000000000000000000000000008152600401610c78919061407d565b600081613212602b82614ff9565b15613249576040517fbcbb94ef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61139f613257602b83614573565b61393a565b600081815b848110156133115736600087838861327a602b8361500d565b9261328793929190614790565b915091508382826040516020016132a093929190615020565b604051602081830303815290604052805190602001209350600082826001602b6132ca919061503a565b8181106132d9576132d9614821565b9091013560f81c60011491505080156132fa57856132f68161504d565b9650505b505050602b8161330a919061500d565b9050613261565b50935093915050565b60006021821015613357576040517fe907cd4f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028383600081612dbe57612dbe614821565b600080600061337985856139cd565b9250925092506000836fffffffffffffffffffffffffffffffff161180156133bc57506133a6828461506c565b6fffffffffffffffffffffffffffffffff163414155b156133f3576040517f07098ab800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3460005b82518160ff1610156135c1576000838260ff168151811061341a5761341a614821565b6020026020010151905060006134338260000151613b4c565b90506000613442836020015190565b90506000876fffffffffffffffffffffffffffffffff16118015613467575082606001515b156135415761348a81886fffffffffffffffffffffffffffffffff166001613ba0565b156134ed57604080516001600160a01b03831681526fffffffffffffffffffffffffffffffff891660208201819052909603957f2d0eb51492ddbee9e95192a44349b114ecfdaacebba5e8aa735b12f14ab1affa910160405180910390a1613541565b604080516001600160a01b03831681526fffffffffffffffffffffffffffffffff891660208201527f4e2061832d78c1622b4b41b221d1791733ba77cd67e86bba10b3e61194d55eb2910160405180910390a15b816001600160a01b031663434def558d8d878588604001516040518663ffffffff1660e01b8152600401613579959493929190615098565b600060405180830381600087803b15801561359357600080fd5b505af11580156135a7573d6000803e3d6000fd5b5050505050505080806135b99061504d565b9150506133f7565b5080156135e0576006546135e0906001600160a01b0316826000613bc7565b5050505050505050565b6000806000806135fa8686612dd2565b9350935093509350600061360b8490565b9050600061361886613b4c565b6040517f203bd15f0000000000000000000000000000000000000000000000000000000081529091506001600160a01b0382169063203bd15f90613668908d908d9087908a908a906004016150de565b600060405180830381600087803b15801561368257600080fd5b505af1158015613696573d6000803e3d6000fd5b5050505050505050505050505050565b60606001868686856136ee5786868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061371c92505050565b6001600160a01b038b16878760405160200161370c93929190615020565b6040516020818303038152906040525b604051602001613730959493929190615123565b60405160208183030381529060405290509695505050505050565b606061139f8460018585611824565b63ffffffff811660009081526008602090815260408083208151808301909252546fffffffffffffffffffffffffffffffff80821680845270010000000000000000000000000000000090920416928201839052928390036137e8576040517fc960f36b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50915091565b60006fffffffffffffffffffffffffffffffff821115613890576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610c78565b5090565b60608160000151826020015183604001518460600151604051602001613924949392919060f09490941b7fffff000000000000000000000000000000000000000000000000000000000000168452600284019290925260c01b7fffffffffffffffff000000000000000000000000000000000000000000000000166022830152151560f81b602a820152602b0190565b6040516020818303038152906040529050919050565b600060ff821115613890576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203860448201527f20626974730000000000000000000000000000000000000000000000000000006064820152608401610c78565b6000806060836021811015613a0e576040517f262c503d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613a1c601160018789614790565b613a25916151cd565b60801c9350613a38602160118789614790565b613a41916151cd565b60801c92506000602b613a5560218461503a565b613a5f9190614573565b90508067ffffffffffffffff811115613a7a57613a7a614515565b604051908082528060200260200182016040528015613acc57816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181613a985790505b509250602160005b828160ff161015613b4157613b0289838a613af0602b8361500d565b92613afd93929190614790565b613c0d565b858260ff1681518110613b1757613b17614821565b6020908102919091010152613b2d602b8361500d565b915080613b398161504d565b915050613ad4565b505050509250925092565b61ffff81166000908152600560205260409020546001600160a01b031680612ece576040517f8b6fecb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008082613bae575a613bb2565b6001545b9050600080600080878986f195945050505050565b613bd2838383613ba0565b613c08576040517f7c75c3d200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b604080516080810182526000808252602082018190529181018290526060810182905290613c3e6002828587614790565b613c4791614d2c565b60f01c90506000613c5c602260028688614790565b613c6591614d74565b90506000613c77602a60228789614790565b613c8091614d92565b60c01c90506000613c95602b602a888a614790565b613c9e91615213565b6040805160808101825261ffff969096168652602086019490945267ffffffffffffffff929092169284019290925260f81c6001146060830152509392505050565b604051806060016040528060008019168152602001600067ffffffffffffffff168152602001613d23604051806040016040528060008152602001600081525090565b905290565b803563ffffffff81168114612ece57600080fd5b60008083601f840112613d4e57600080fd5b50813567ffffffffffffffff811115613d6657600080fd5b602083019150836020828501011115613d7e57600080fd5b9250929050565b600080600060408486031215613d9a57600080fd5b613da384613d28565b9250602084013567ffffffffffffffff811115613dbf57600080fd5b613dcb86828701613d3c565b9497909650939450505050565b815181526020808301519082015260408101611020565b600060608284031215613e0157600080fd5b50919050565b80356001600160a01b0381168114612ece57600080fd5b600080600080600080600060e0888a031215613e3957600080fd5b613e438989613def565b965060608801359550608088013567ffffffffffffffff80821115613e6757600080fd5b613e738b838c01613d3c565b9097509550859150613e8760a08b01613e07565b945060c08a0135915080821115613e9d57600080fd5b50613eaa8a828b01613d3c565b989b979a50959850939692959293505050565b803569ffffffffffffffffffff81168114612ece57600080fd5b600080600060608486031215613eec57600080fd5b613ef584613d28565b9250613f0360208501613ebd565b9150613f1160408501613ebd565b90509250925092565b60008060408385031215613f2d57600080fd5b613f3683613d28565b9150602083013560ff81168114613f4c57600080fd5b809150509250929050565b600060c08284031215613e0157600080fd5b80358015158114612ece57600080fd5b60008060408385031215613f8c57600080fd5b823567ffffffffffffffff811115613fa357600080fd5b613faf85828601613f57565b925050613fbe60208401613f69565b90509250929050565b60008060408385031215613fda57600080fd5b613fe383613d28565b946020939093013593505050565b803561ffff81168114612ece57600080fd5b6000806040838503121561401657600080fd5b61401f83613d28565b9150613fbe60208401613ff1565b60005b83811015614048578181015183820152602001614030565b50506000910152565b6000815180845261406981602086016020860161402d565b601f01601f19169290920160200192915050565b6020815260006140906020830184614051565b9392505050565b6000602082840312156140a957600080fd5b61409082613ff1565b8051825267ffffffffffffffff60208201511660208301526040810151613c08604084018280518252602090810151910152565b6080810161102082846140b2565b80356fffffffffffffffffffffffffffffffff81168114612ece57600080fd5b6000806040838503121561412757600080fd5b61413083613d28565b9150613fbe602084016140f4565b60006020828403121561415057600080fd5b61409082613d28565b6000806040838503121561416c57600080fd5b61417583613d28565b9150613fbe60208401613f69565b60008060008060a0858703121561419957600080fd5b6141a38686613def565b9350606085013567ffffffffffffffff8111156141bf57600080fd5b6141cb87828801613d3c565b90945092506141de905060808601613e07565b905092959194509250565b6000602082840312156141fb57600080fd5b61409082613e07565b600060a08284031215613e0157600080fd5b61422081846140b2565b60a0608082015268ffffffffffffffffff82511660a082015260006020830151604060c0840152610f4360e0840182614051565b60006020828403121561426657600080fd5b5035919050565b6000806040838503121561428057600080fd5b61401f83613e07565b60008083601f84011261429b57600080fd5b50813567ffffffffffffffff8111156142b357600080fd5b6020830191508360208260051b8501011115613d7e57600080fd5b600080602083850312156142e157600080fd5b823567ffffffffffffffff8111156142f857600080fd5b61430485828601614289565b90969095509350505050565b6000806000806060858703121561432657600080fd5b61432f85613d28565b935061433d60208601613ff1565b9250604085013567ffffffffffffffff81111561435957600080fd5b61436587828801613d3c565b95989497509550505050565b6000806000806060858703121561438757600080fd5b843567ffffffffffffffff81111561439e57600080fd5b6143aa87828801614289565b90955093506143bd905060208601613ff1565b91506141de60408601613ff1565b6000806000606084860312156143e057600080fd5b6143e984613d28565b92506143f7602085016140f4565b9150613f11604085016140f4565b6000806000838503608081121561441b57600080fd5b843567ffffffffffffffff81111561443257600080fd5b61443e87828801613f57565b9450506040601f198201121561445357600080fd5b50602084019150613f1160608501613e07565b60006060828403121561447857600080fd5b6140908383613def565b600181811c9082168061449657607f821691505b602082108103613e01577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082028115828204841417611020576110206144cf565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261458257614582614544565b500490565b67ffffffffffffffff8116811461208e57600080fd5b6000602082840312156145af57600080fd5b813561409081614587565b6000602082840312156145cc57600080fd5b61409082613f69565b6040516060810167ffffffffffffffff811182821017156145f8576145f8614515565b60405290565b6040805190810167ffffffffffffffff811182821017156145f8576145f8614515565b604051601f8201601f1916810167ffffffffffffffff8111828210171561464a5761464a614515565b604052919050565b600067ffffffffffffffff82111561466c5761466c614515565b50601f01601f191660200190565b600067ffffffffffffffff8084111561469557614695614515565b8360051b60206146a6818301614621565b8681529185019181810190368411156146be57600080fd5b865b84811015614784578035868111156146d85760008081fd5b880160603682900312156146ec5760008081fd5b6146f46145d5565b6146fd82613d28565b815261470a868301613ff1565b86820152604080830135898111156147225760008081fd5b929092019136601f8401126147375760008081fd5b823561474a61474582614652565b614621565b818152368983870101111561475f5760008081fd5b818986018a8301376000918101890191909152908201528452509183019183016146c0565b50979650505050505050565b600080858511156147a057600080fd5b838611156147ad57600080fd5b5050820193919092039150565b600084516147cc81846020890161402d565b8201838582376000930192835250909392505050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b60208152600061139f6020830184866147e2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec183360301811261488457600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126148c357600080fd5b83018035915067ffffffffffffffff8211156148de57600080fd5b602001915036819003821315613d7e57600080fd5b63ffffffff61490182613d28565b16825260208101356020830152604081013561491c81614587565b67ffffffffffffffff81166040840152505050565b61493b81896148f3565b86606082015260e06080820152600061495860e0830187896147e2565b6001600160a01b03861660a084015282810360c084015261497a8185876147e2565b9a9950505050505050505050565b60006020828403121561499a57600080fd5b815167ffffffffffffffff8111156149b157600080fd5b8201601f810184136149c257600080fd5b80516149d061474582614652565b8181528560208385010111156149e557600080fd5b610f4382602083016020860161402d565b68ffffffffffffffffff818116838216019080821115614a1857614a186144cf565b5092915050565b61ffff828116828216039080821115614a1857614a186144cf565b600061ffff808316818103614a5157614a516144cf565b6001019392505050565b600060408284031215614a6d57600080fd5b614a756145fe565b82358152602083013560208201528091505092915050565b68ffffffffffffffffff828116828216039080821115614a1857614a186144cf565b600068ffffffffffffffffff80841680614acb57614acb614544565b92169190910692915050565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a06080840152614b0d60e0840182614051565b905060608501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08483030160a0850152614b488282614051565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b600060408284031215614b8057600080fd5b614b886145fe565b9050815181526020820151602082015292915050565b600060408284031215614bb057600080fd5b6140908383614b6e565b600060808284031215614bcc57600080fd5b614bd46145d5565b825181526020830151614be681614587565b6020820152614bf88460408501614b6e565b60408201529392505050565b7fff000000000000000000000000000000000000000000000000000000000000008560f81b16815260007fffffffffffffffffffffffffffffffff00000000000000000000000000000000808660801b166001840152808560801b166011840152508251614c7981602185016020870161402d565b9190910160210195945050505050565b6fffffffffffffffffffffffffffffffff818116838216019080821115614a1857614a186144cf565b60008351614cc481846020880161402d565b835190830190614cd881836020880161402d565b01949350505050565b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b16815260008251614d1e81600285016020870161402d565b919091016002019392505050565b7fffff0000000000000000000000000000000000000000000000000000000000008135818116916002851015614d6c5780818660020360031b1b83161692505b505092915050565b8035602083101561102057600019602084900360031b1b1692915050565b7fffffffffffffffff0000000000000000000000000000000000000000000000008135818116916008851015614d6c5760089490940360031b84901b1690921692915050565b82815260008251614df081602085016020870161402d565b919091016020019392505050565b63ffffffff8516815268ffffffffffffffffff8416602082015269ffffffffffffffffffff831660408201526080606082015260006121726080830184614051565b601f821115613c08576000816000526020600020601f850160051c81016020861015614e695750805b601f850160051c820191505b81811015614e8857828155600101614e75565b505050505050565b815167ffffffffffffffff811115614eaa57614eaa614515565b614ebe81614eb88454614482565b84614e40565b602080601f831160018114614ef35760008415614edb5750858301515b600019600386901b1c1916600185901b178555614e88565b600085815260208120601f198616915b82811015614f2257888601518255948401946001909101908401614f03565b5085821015614f405787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b83811015614feb578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00185528151805163ffffffff1684528781015161ffff16888501528601516060878501819052614fd781860183614051565b968901969450505090860190600101614f79565b509098975050505050505050565b60008261500857615008614544565b500690565b80820180821115611020576110206144cf565b838152818360208301376000910160200190815292915050565b81810381811115611020576110206144cf565b600060ff821660ff8103615063576150636144cf565b60010192915050565b6fffffffffffffffffffffffffffffffff818116838216028082169190828114614d6c57614d6c6144cf565b60e081016150a682886148f3565b85606083015260ff851660808301526001600160a01b03841660a083015267ffffffffffffffff831660c08301529695505050505050565b6150e881876148f3565b8460608201526001600160a01b038416608082015267ffffffffffffffff831660a082015260e060c08201526000610c0d60e0830184614051565b7fff000000000000000000000000000000000000000000000000000000000000008660f81b1681527fffff0000000000000000000000000000000000000000000000000000000000008560f01b1660018201528360038201527fffffffffffffffff0000000000000000000000000000000000000000000000008360c01b166023820152600082516151bc81602b85016020870161402d565b91909101602b019695505050505050565b7fffffffffffffffffffffffffffffffff000000000000000000000000000000008135818116916010851015614d6c5760109490940360031b84901b1690921692915050565b7fff000000000000000000000000000000000000000000000000000000000000008135818116916001851015614d6c5760019490940360031b84901b169092169291505056fea26469706673582212204c1570096025a76a2e4ca153aea4e131278048f317a85384ee094b7ff1a7e86064736f6c634300081600330000000000000000000000001a44076050125825900e736c501f859c50fe728c0000000000000000000000004a79adc4539905376d339c69b6a7092d0598cc240000000000000000000000000000000000000000000000000000000000000200
Deployed Bytecode
0x60806040526004361061031e5760003560e01c806385afd453116101a5578063c239f1ad116100ec578063ee5ccf6a11610095578063fd6f05571161006f578063fd6f055714610af5578063fdee84ec14610b15578063ff6fb30014610b5d578063ff7bd03d14610b7057600080fd5b8063ee5ccf6a14610a35578063f2fde38b14610a55578063f8d50da614610a7557600080fd5b8063d4243885116100c6578063d4243885146109c4578063d8e8dbc7146109e4578063e4c572cc14610a1557600080fd5b8063c239f1ad1461097c578063ca5eb5e114610991578063d045a0dc146109b157600080fd5b8063917df23b1161014e578063bb0b6a5311610128578063bb0b6a531461091c578063bc70b35414610949578063bd815db01461096957600080fd5b8063917df23b146108a9578063b731ea0a146108dc578063b98bd070146108fc57600080fd5b80638da5cb5b1161017f5780638da5cb5b146108245780638f71f7dd1461084257806390fdb20c1461086257600080fd5b806385afd453146107b757806388543f0e146107e55780638c70830b1461080457600080fd5b80635e280f1111610269578063731dbe0c116102125780637d25a05e116101ec5780637d25a05e1461073b57806382413eac14610777578063826f1fb11461079757600080fd5b8063731dbe0c1461068657806375d2208c146106e65780637845ca231461070657600080fd5b80636763d689116102435780636763d689146105695780636ad9914d14610589578063715018a61461067157600080fd5b80635e280f11146104df5780635f6d9ae41461051357806364e4ac271461054957600080fd5b806332e4e363116102cb57806352ae2879116102a557806352ae28791461046f5780635535d461146104825780635a0dfe4d146104af57600080fd5b806332e4e363146103f05780633400288b1461042857806345655a161461044857600080fd5b80632b28b34e116102fc5780632b28b34e146103905780632dca2f51146103b05780633292cf02146103d057600080fd5b8063086431ec1461032357806313137d651461035957806317442b701461036e575b600080fd5b34801561032f57600080fd5b5061034361033e366004613d85565b610b90565b6040516103509190613dd8565b60405180910390f35b61036c610367366004613e1e565b610c18565b005b34801561037a57600080fd5b5060408051600181526002602082015201610350565b34801561039c57600080fd5b5061036c6103ab366004613ed7565b610d0a565b3480156103bc57600080fd5b5061036c6103cb366004613f1a565b610e33565b3480156103dc57600080fd5b506103436103eb366004613f79565b610f03565b3480156103fc57600080fd5b50600654610410906001600160a01b031681565b6040516001600160a01b039091168152602001610350565b34801561043457600080fd5b5061036c610443366004613fc7565b610f4c565b34801561045457600080fd5b5061045d600181565b60405160ff9091168152602001610350565b34801561047b57600080fd5b5030610410565b34801561048e57600080fd5b506104a261049d366004614003565b610f62565b604051610350919061407d565b3480156104bb57600080fd5b506104cf6104ca366004613fc7565b611007565b6040519015158152602001610350565b3480156104eb57600080fd5b506104107f0000000000000000000000001a44076050125825900e736c501f859c50fe728c81565b34801561051f57600080fd5b5061041061052e366004614097565b6005602052600090815260409020546001600160a01b031681565b61055c610557366004613d85565b611026565b60405161035091906140e6565b34801561057557600080fd5b5061036c610584366004614114565b61111e565b34801561059557600080fd5b506106266105a436600461413e565b60096020526000908152604090205460ff81169069ffffffffffffffffffff61010082048116916b01000000000000000000000081049091169061ffff75010000000000000000000000000000000000000000008204169068ffffffffffffffffff770100000000000000000000000000000000000000000000009091041685565b6040805160ff96909616865269ffffffffffffffffffff9485166020870152929093169184019190915261ffff16606083015268ffffffffffffffffff16608082015260a001610350565b34801561067d57600080fd5b5061036c6111ad565b34801561069257600080fd5b506106c56106a136600461413e565b600a602052600090815260409020546fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff9091168152602001610350565b3480156106f257600080fd5b50610343610701366004614159565b6111c1565b34801561071257600080fd5b50610726610721366004613f1a565b61120b565b60408051928352602083019190915201610350565b34801561074757600080fd5b5061075e610756366004613fc7565b600092915050565b60405167ffffffffffffffff9091168152602001610350565b34801561078357600080fd5b506104cf610792366004614183565b611346565b3480156107a357600080fd5b5061036c6107b23660046141e9565b6113a7565b3480156107c357600080fd5b506107d76107d2366004614204565b61141c565b604051610350929190614216565b3480156107f157600080fd5b506001545b604051908152602001610350565b34801561081057600080fd5b5061036c61081f366004614254565b61153b565b34801561083057600080fd5b506000546001600160a01b0316610410565b34801561084e57600080fd5b5061036c61085d36600461426d565b611548565b34801561086e57600080fd5b506108967f000000000000000000000000000000000000000000000000000000000000020081565b60405161ffff9091168152602001610350565b3480156108b557600080fd5b506003546108969074010000000000000000000000000000000000000000900461ffff1681565b3480156108e857600080fd5b50600354610410906001600160a01b031681565b34801561090857600080fd5b5061036c6109173660046142ce565b61180a565b34801561092857600080fd5b506107f661093736600461413e565b60026020526000908152604090205481565b34801561095557600080fd5b506104a2610964366004614310565b611824565b61036c6109773660046142ce565b6119e5565b34801561098857600080fd5b5061045d600281565b34801561099d57600080fd5b5061036c6109ac3660046141e9565b611b71565b61036c6109bf366004613e1e565b611c10565b3480156109d057600080fd5b5061036c6109df3660046141e9565b611c58565b3480156109f057600080fd5b506108966109ff3660046141e9565b60046020526000908152604090205461ffff1681565b348015610a2157600080fd5b5061036c610a30366004614097565b611cc6565b348015610a4157600080fd5b5061036c610a50366004614371565b611d49565b348015610a6157600080fd5b5061036c610a703660046141e9565b611fe7565b348015610a8157600080fd5b50610acc610a9036600461413e565b6008602052600090815260409020546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b604080516fffffffffffffffffffffffffffffffff938416815292909116602083015201610350565b348015610b0157600080fd5b5061036c610b103660046143cb565b612091565b348015610b2157600080fd5b506107f6610b30366004614003565b63ffffffff909116600090815260096020908152604080832061ffff909416835260019093019052205490565b61055c610b6b366004614405565b61212f565b348015610b7c57600080fd5b506104cf610b8b366004614466565b61217c565b604080518082019091526000808252602082015263ffffffff80851660009081526009602052604081209091610bed91907f000000000000000000000000000000000000000000000000000000000000020090879087906121b216565b9050600080610bfc87846123cd565b91509150610c0d878383600061243a565b979650505050505050565b7f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b03163314610c81576040517f91ac5e4f0000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b60208701803590610c9b90610c96908a61413e565b612512565b14610cf257610cad602088018861413e565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff909116600482015260208801356024820152604401610c78565b610d0187878787878787612567565b50505050505050565b6006546001600160a01b03163314610d4e576040517fc63aab2c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000760663ffffffff168363ffffffff1603610db3576040517fa27dd10200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff8084166000908152600960205260409020610dd7918490849061259316565b6040805163ffffffff8516815269ffffffffffffffffffff80851660208301528316918101919091527fd2245824774f1c2de21256e9fb34d9cc4633cf72c0952a82a996e45ad4df3c70906060015b60405180910390a1505050565b610e3b612603565b7f000000000000000000000000000000000000000000000000000000000000020061ffff168160ff1610610e9b576040517f31843b5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff8083166000908152600960205260409020610ebd91839061267716565b6040805163ffffffff8416815260ff831660208201527ff9fa6c3c4dbf13c4a8348c3102ef22789aa450b81e492b853e93f9701e08958091015b60405180910390a15050565b6040805180820190915260008082526020820152600080610f23856126a6565b9092509050610f43610f3b604087016020880161413e565b83838761243a565b95945050505050565b610f54612603565b610f5e828261271d565b5050565b600760209081526000928352604080842090915290825290208054610f8690614482565b80601f0160208091040260200160405190810160405280929190818152602001828054610fb290614482565b8015610fff5780601f10610fd457610100808354040283529160200191610fff565b820191906000526020600020905b815481529060010190602001808311610fe257829003601f168201915b505050505081565b63ffffffff821660009081526002602052604090205481145b92915050565b61102e613ce0565b63ffffffff8085166000908152600960205260408120909161107791907f0000000000000000000000000000000000000000000000000000000000000200908790879061276b16565b905060008061108687846123cd565b915091506110ac8783836040518060400160405280348152602001600081525033612865565b835160208086015183516040805163ffffffff8e16815268ffffffffffffffffff9095169385019390935260ff909116838301526060830152519195507f1623f9ea59bd6f214c9571a892da012fc23534aa5906bef4ae8c5d15ee7d2d6e919081900360800190a15050509392505050565b611126612603565b63ffffffff82166000818152600a602090815260409182902080547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff86169081179091558251938452908301527f5b9fac6cf74b12ad67aa143075523ab25ca781b0f611c4897b31d1500f2ae9629101610ef7565b6111b5612603565b6111bf600061293e565b565b604080518082019091526000808252602082015263ffffffff80841660009081526009602052604090206111f79184906129a616565b69ffffffffffffffffffff16815292915050565b6000808260ff1660000361124b576040517fe3a9395200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061125b602b60ff86166144fe565b67ffffffffffffffff81111561127357611273614515565b6040519080825280601f01601f19166020018201604052801561129d576020820181803683370190505b50905060006112ae60008084612a2f565b905060006112bf8787600080612a61565b90508560ff166112d2888484600061243a565b516112dd9190614573565b63ffffffff88166000908152600a60205260408120549196509061131b908990899060ff8216906fffffffffffffffffffffffffffffffff16612a61565b90508660ff1661132e898584600061243a565b516113399190614573565b9450505050509250929050565b60006113528484612d6e565b1561139b5760006113638585612dd2565b50505061ffff81166000908152600560205260409020549091506001600160a01b0380851691160361139957600191505061139f565b505b5060005b949350505050565b6113af612603565b600680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f5767d79cd17d7554509a4dd59a5a7a9175c7e36466455d7b2fa4788228808579906020015b60405180910390a150565b611424613ce0565b604080518082019091526000815260606020820152600061144433612e77565b90506000611458604086016020870161413e565b905060008060006114f97f00000000000000000000000000000000000000000000000000000000000002008560405180608001604052808961ffff1681526020018c6040013581526020018c60600160208101906114b6919061459d565b67ffffffffffffffff1681526020016114d560a08e0160808f016145ba565b1515905263ffffffff808916600090815260096020526040902093929190612ed316565b60408051808201825268ffffffffffffffffff909416845260208401929092529089015169ffffffffffffffffffff9190911690529698969750505050505050565b611543612603565b600155565b611550612603565b8061ffff1660000361158e576040517fe447547600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60035461ffff740100000000000000000000000000000000000000009091048116908216111561163757600380547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c0179060200160405180910390a15b6001600160a01b0380831660009081526004602090815260408083205461ffff868116855260059093529220549116911681156116a85761ffff8216600090815260056020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b6001600160a01b038116156116f6576001600160a01b038116600090815260046020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001690555b6001600160a01b0384166117425761ffff8316600090815260056020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556117bf565b6001600160a01b038416600081815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff891690811790915583526005909152902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690911790555b604080516001600160a01b038616815261ffff851660208201527fac53470cf8e9e3d673caa7d47cd7db36c0d38cf37fc147c70c92bc0c1c4734f5910160405180910390a150505050565b611812612603565b610f5e61181f828461467a565b6130b8565b63ffffffff8416600090815260076020908152604080832061ffff8716845290915281208054606092919061185890614482565b80601f016020809104026020016040519081016040528092919081815260200182805461188490614482565b80156118d15780601f106118a6576101008083540402835291602001916118d1565b820191906000526020600020905b8154815290600101906020018083116118b457829003601f168201915b5050505050905080516000036119215783838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092945061139f9350505050565b600083900361193157905061139f565b600283106119af5761197884848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506131bf92505050565b806119868460028188614790565b604051602001611998939291906147ba565b60405160208183030381529060405291505061139f565b83836040517f9a6d49cd000000000000000000000000000000000000000000000000000000008152600401610c7892919061480d565b60005b81811015611ad75736838383818110611a0357611a03614821565b9050602002810190611a159190614850565b9050611a31611a27602083018361413e565b6020830135611007565b611a3b5750611acf565b3063d045a0dc60c08301358360a0810135611a5a61010083018361488e565b611a6b610100890160e08a016141e9565b611a796101208a018a61488e565b6040518963ffffffff1660e01b8152600401611a9b9796959493929190614931565b6000604051808303818588803b158015611ab457600080fd5b505af1158015611ac8573d6000803e3d6000fd5b5050505050505b6001016119e8565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611b16573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b3e9190810190614988565b6040517f8351eea7000000000000000000000000000000000000000000000000000000008152600401610c78919061407d565b611b79612603565b6040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c169063ca5eb5e190602401600060405180830381600087803b158015611bf557600080fd5b505af1158015611c09573d6000803e3d6000fd5b5050505050565b333014611c49576040517f14d4a4e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d0187878787878787610cf2565b611c60612603565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c242776090602001611411565b611cce612603565b600380547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c01790602001611411565b611d51612603565b60005b83811015611c0957600060096000878785818110611d7457611d74614821565b9050602002016020810190611d89919061413e565b63ffffffff1681526020810191909152604001600020805490915061ffff7f0000000000000000000000000000000000000000000000000000000000000200811691611e169175010000000000000000000000000000000000000000008204169068ffffffffffffffffff77010000000000000000000000000000000000000000000000909104166149f6565b68ffffffffffffffffff161115611e2d5750611fdf565b8054600090611e7f907501000000000000000000000000000000000000000000810461ffff169077010000000000000000000000000000000000000000000000900468ffffffffffffffffff166149f6565b905060008161ffff168661ffff161015611e995781611e9b565b855b90506000611eca60017f0000000000000000000000000000000000000000000000000000000000000200614a1f565b61ffff168661ffff161015611edf5785611f0a565b611f0a60017f0000000000000000000000000000000000000000000000000000000000000200614a1f565b9050815b8161ffff168161ffff1611611f675761ffff8116600090815260018601602052604090207f4600000000000000000000000000000000000000000000000000000000000000905580611f5f81614a3a565b915050611f0e565b507f68ae5a72b18bd3a6fbbc56d3cddb8a1c567b1d6ad4e705dd0b9295de05262bf4898987818110611f9b57611f9b614821565b9050602002016020810190611fb0919061413e565b6040805163ffffffff909216825261ffff808616602084015284169082015260600160405180910390a1505050505b600101611d54565b611fef612603565b6001600160a01b038116612085576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610c78565b61208e8161293e565b50565b612099612603565b6040805180820182526fffffffffffffffffffffffffffffffff848116808352848216602080850182815263ffffffff8a16600081815260088452889020965191518616700100000000000000000000000000000000029190951617909455845192835292820152918201527fff958b7fbea293188b750425e92bd9c7a646f9063b9fc7722ae861802a7a1fe790606001610e26565b612137613ce0565b600080612143866126a6565b909250905061217261215b604088016020890161413e565b838361216c368a90038a018a614a5b565b88612865565b9695505050505050565b6000602082018035906002908390612194908661413e565b63ffffffff1681526020810191909152604001600020541492915050565b60408051608081018252600080825260208201819052918101829052606080820152906121df8484613204565b905060ff811615806121f85750855460ff908116908216115b80612223575085547501000000000000000000000000000000000000000000900461ffff1660ff8216115b1561225f576040517fc5ad74c700000000000000000000000000000000000000000000000000000000815260ff82166004820152602401610c78565b855477010000000000000000000000000000000000000000000000900468ffffffffffffffffff16600081156122cd578760010160008861ffff166001856122a79190614a8d565b6122b19190614aaf565b61ffff1661ffff168152602001908152602001600020546122d0565b60005b90506000806122e088888561325c565b9092509050600060016122f660ff8816876149f6565b6123009190614a8d565b905060018b01600061231661ffff8d1684614aaf565b61ffff1661ffff168152602001908152602001600020548214612365576040517f5b3f67cd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b68ffffffffffffffffff8516875260ff861660208089019190915260408051601f8b01839004830281018301909152898152908a908a90819084018382808284376000920191909152505050506060880152505060ff16604085015250919695505050505050565b63ffffffff82166000908152600a6020526040908190205490820151606083810151909283926fffffffffffffffffffffffffffffffff909116916124179160ff16908390612a2f565b9250612430858560200151866040015160ff1684612a61565b9150509250929050565b60408051808201909152600080825260208201527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b031663ddc28c586040518060a001604052808863ffffffff16815260200161249d89612512565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b81526004016124d2929190614ad7565b6040805180830381865afa1580156124ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f439190614b9e565b63ffffffff811660009081526002602052604081205480611020576040517ff6ff4fb700000000000000000000000000000000000000000000000000000000815263ffffffff84166004820152602401610c78565b612571858561331a565b15612587576125828787878761336a565b610d01565b610d01878787876135ea565b82547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1661010069ffffffffffffffffffff938416027fffffffffffffffffffffff00000000000000000000ffffffffffffffffffffff16176b0100000000000000000000009190921602179055565b6000546001600160a01b031633146111bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c78565b81547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff91909116179055565b60608060006126b433612e77565b90506126ee6126c660208601866141e9565b8260408701356126dc6080890160608a0161459d565b6126e960808a018a61488e565b6136a6565b9250612715612703604086016020870161413e565b61271060a087018761488e565b61374b565b915050915091565b63ffffffff8216600081815260026020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b9101610ef7565b604080516080810182526000808252602082018190529181019190915260608082015261279a858585856121b2565b6020810151865460ff90911661ffff750100000000000000000000000000000000000000000068ffffffffffffffffff77010000000000000000000000000000000000000000000000808604821685019091160276ffffffffffffffffffffffffffffffffffffffffffffff85168117829004831693909303909116027fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff90911674ffffffffffffffffffffffffffffffffffffffffff909216919091171790955550929392505050565b61286d613ce0565b82517f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b0316632637a450826040518060a001604052808b63ffffffff1681526020016128bf8c612512565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b81526004016128fb929190614ad7565b60806040518083038185885af1158015612919573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c0d9190614bba565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000816129c5578254610100900469ffffffffffffffffffff166129e3565b82546b010000000000000000000000900469ffffffffffffffffffff165b90508069ffffffffffffffffffff16600003611020576040517f5bc181900000000000000000000000000000000000000000000000000000000081528215156004820152602401610c78565b60606002848484604051602001612a499493929190614c04565b60405160208183030381529060405290509392505050565b6060600080612a6f8761375a565b90925090506000612a9d612a9860ff89166fffffffffffffffffffffffffffffffff86166144fe565b6137ee565b90506000612ac0612a986fffffffffffffffffffffffffffffffff8816896144fe565b90506fffffffffffffffffffffffffffffffff811615612b0657612af9612a98886fffffffffffffffffffffffffffffffff86166144fe565b612b039083614c89565b91505b600080826fffffffffffffffffffffffffffffffff1611612bb9576040517f0100000000000000000000000000000000000000000000000000000000000000602082018190527e11000000000000000000000000000000000000000000000000000000000000602183015260238201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608085901b166024820152603401604051602081830303815290604052612c57565b6040517f0100000000000000000000000000000000000000000000000000000000000000602082018190527e21000000000000000000000000000000000000000000000000000000000000602183015260238201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608085811b8216602484015284901b1660348201526044016040516020818303038152906040525b63ffffffff8b16600090815260076020908152604080832060028452909152812080549293509091612c8890614482565b80601f0160208091040260200160405190810160405280929190818152602001828054612cb490614482565b8015612d015780601f10612cd657610100808354040283529160200191612d01565b820191906000526020600020905b815481529060010190602001808311612ce457829003601f168201915b505050505090506002815110612d3a578082604051602001612d24929190614cb2565b6040516020818303038152906040529650612d60565b600382604051602001612d4e929190614ce1565b60405160208183030381529060405296505b505050505050949350505050565b6000602b821015612dab576040517fde01ff2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018383600081612dbe57612dbe614821565b919091013560f81c91909114949350505050565b600080806060612de6600360018789614790565b612def91614d2c565b60f01c9350612e02602360038789614790565b612e0b91614d74565b9250612e1b602b60238789614790565b612e2491614d92565b60c01c9150612e3685602b8189614790565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509699959850939650909450505050565b6001600160a01b03811660009081526004602052604081205461ffff1690819003612ece576040517f8b6fecb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b8354600161ffff75010000000000000000000000000000000000000000008084048216928301821681027fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff9094169390931780885568ffffffffffffffffff7701000000000000000000000000000000000000000000000082041690920192606092600092888116929091041610612f97576040517ffa36e2ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612fa084613894565b9150612fb98460600151886129a690919063ffffffff16565b9050600068ffffffffffffffffff841615613012578760010160008861ffff166001870368ffffffffffffffffff1681612ff557612ff5614544565b0661ffff1661ffff16815260200190815260200160002054613015565b60005b9050808360405160200161302a929190614dd8565b604051602081830303815290604052805190602001208860010160008961ffff16876130569190614aaf565b61ffff1661ffff168152602001908152602001600020819055507f15955c5a4cc61b8fbb05301bce47fd31c0e6f935e1ab97fdac9b134c887bb074868584866040516130a59493929190614dfe565b60405180910390a1509450945094915050565b60005b815181101561318f576130ea8282815181106130d9576130d9614821565b6020026020010151604001516131bf565b8181815181106130fc576130fc614821565b6020026020010151604001516007600084848151811061311e5761311e614821565b60200260200101516000015163ffffffff1663ffffffff168152602001908152602001600020600084848151811061315857613158614821565b60200260200101516020015161ffff1661ffff16815260200190815260200160002090816131869190614e90565b506001016130bb565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b674816040516114119190614f50565b600281015161ffff8116600314610f5e57816040517f9a6d49cd000000000000000000000000000000000000000000000000000000008152600401610c78919061407d565b600081613212602b82614ff9565b15613249576040517fbcbb94ef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61139f613257602b83614573565b61393a565b600081815b848110156133115736600087838861327a602b8361500d565b9261328793929190614790565b915091508382826040516020016132a093929190615020565b604051602081830303815290604052805190602001209350600082826001602b6132ca919061503a565b8181106132d9576132d9614821565b9091013560f81c60011491505080156132fa57856132f68161504d565b9650505b505050602b8161330a919061500d565b9050613261565b50935093915050565b60006021821015613357576040517fe907cd4f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028383600081612dbe57612dbe614821565b600080600061337985856139cd565b9250925092506000836fffffffffffffffffffffffffffffffff161180156133bc57506133a6828461506c565b6fffffffffffffffffffffffffffffffff163414155b156133f3576040517f07098ab800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3460005b82518160ff1610156135c1576000838260ff168151811061341a5761341a614821565b6020026020010151905060006134338260000151613b4c565b90506000613442836020015190565b90506000876fffffffffffffffffffffffffffffffff16118015613467575082606001515b156135415761348a81886fffffffffffffffffffffffffffffffff166001613ba0565b156134ed57604080516001600160a01b03831681526fffffffffffffffffffffffffffffffff891660208201819052909603957f2d0eb51492ddbee9e95192a44349b114ecfdaacebba5e8aa735b12f14ab1affa910160405180910390a1613541565b604080516001600160a01b03831681526fffffffffffffffffffffffffffffffff891660208201527f4e2061832d78c1622b4b41b221d1791733ba77cd67e86bba10b3e61194d55eb2910160405180910390a15b816001600160a01b031663434def558d8d878588604001516040518663ffffffff1660e01b8152600401613579959493929190615098565b600060405180830381600087803b15801561359357600080fd5b505af11580156135a7573d6000803e3d6000fd5b5050505050505080806135b99061504d565b9150506133f7565b5080156135e0576006546135e0906001600160a01b0316826000613bc7565b5050505050505050565b6000806000806135fa8686612dd2565b9350935093509350600061360b8490565b9050600061361886613b4c565b6040517f203bd15f0000000000000000000000000000000000000000000000000000000081529091506001600160a01b0382169063203bd15f90613668908d908d9087908a908a906004016150de565b600060405180830381600087803b15801561368257600080fd5b505af1158015613696573d6000803e3d6000fd5b5050505050505050505050505050565b60606001868686856136ee5786868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061371c92505050565b6001600160a01b038b16878760405160200161370c93929190615020565b6040516020818303038152906040525b604051602001613730959493929190615123565b60405160208183030381529060405290509695505050505050565b606061139f8460018585611824565b63ffffffff811660009081526008602090815260408083208151808301909252546fffffffffffffffffffffffffffffffff80821680845270010000000000000000000000000000000090920416928201839052928390036137e8576040517fc960f36b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50915091565b60006fffffffffffffffffffffffffffffffff821115613890576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610c78565b5090565b60608160000151826020015183604001518460600151604051602001613924949392919060f09490941b7fffff000000000000000000000000000000000000000000000000000000000000168452600284019290925260c01b7fffffffffffffffff000000000000000000000000000000000000000000000000166022830152151560f81b602a820152602b0190565b6040516020818303038152906040529050919050565b600060ff821115613890576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203860448201527f20626974730000000000000000000000000000000000000000000000000000006064820152608401610c78565b6000806060836021811015613a0e576040517f262c503d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613a1c601160018789614790565b613a25916151cd565b60801c9350613a38602160118789614790565b613a41916151cd565b60801c92506000602b613a5560218461503a565b613a5f9190614573565b90508067ffffffffffffffff811115613a7a57613a7a614515565b604051908082528060200260200182016040528015613acc57816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181613a985790505b509250602160005b828160ff161015613b4157613b0289838a613af0602b8361500d565b92613afd93929190614790565b613c0d565b858260ff1681518110613b1757613b17614821565b6020908102919091010152613b2d602b8361500d565b915080613b398161504d565b915050613ad4565b505050509250925092565b61ffff81166000908152600560205260409020546001600160a01b031680612ece576040517f8b6fecb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008082613bae575a613bb2565b6001545b9050600080600080878986f195945050505050565b613bd2838383613ba0565b613c08576040517f7c75c3d200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b604080516080810182526000808252602082018190529181018290526060810182905290613c3e6002828587614790565b613c4791614d2c565b60f01c90506000613c5c602260028688614790565b613c6591614d74565b90506000613c77602a60228789614790565b613c8091614d92565b60c01c90506000613c95602b602a888a614790565b613c9e91615213565b6040805160808101825261ffff969096168652602086019490945267ffffffffffffffff929092169284019290925260f81c6001146060830152509392505050565b604051806060016040528060008019168152602001600067ffffffffffffffff168152602001613d23604051806040016040528060008152602001600081525090565b905290565b803563ffffffff81168114612ece57600080fd5b60008083601f840112613d4e57600080fd5b50813567ffffffffffffffff811115613d6657600080fd5b602083019150836020828501011115613d7e57600080fd5b9250929050565b600080600060408486031215613d9a57600080fd5b613da384613d28565b9250602084013567ffffffffffffffff811115613dbf57600080fd5b613dcb86828701613d3c565b9497909650939450505050565b815181526020808301519082015260408101611020565b600060608284031215613e0157600080fd5b50919050565b80356001600160a01b0381168114612ece57600080fd5b600080600080600080600060e0888a031215613e3957600080fd5b613e438989613def565b965060608801359550608088013567ffffffffffffffff80821115613e6757600080fd5b613e738b838c01613d3c565b9097509550859150613e8760a08b01613e07565b945060c08a0135915080821115613e9d57600080fd5b50613eaa8a828b01613d3c565b989b979a50959850939692959293505050565b803569ffffffffffffffffffff81168114612ece57600080fd5b600080600060608486031215613eec57600080fd5b613ef584613d28565b9250613f0360208501613ebd565b9150613f1160408501613ebd565b90509250925092565b60008060408385031215613f2d57600080fd5b613f3683613d28565b9150602083013560ff81168114613f4c57600080fd5b809150509250929050565b600060c08284031215613e0157600080fd5b80358015158114612ece57600080fd5b60008060408385031215613f8c57600080fd5b823567ffffffffffffffff811115613fa357600080fd5b613faf85828601613f57565b925050613fbe60208401613f69565b90509250929050565b60008060408385031215613fda57600080fd5b613fe383613d28565b946020939093013593505050565b803561ffff81168114612ece57600080fd5b6000806040838503121561401657600080fd5b61401f83613d28565b9150613fbe60208401613ff1565b60005b83811015614048578181015183820152602001614030565b50506000910152565b6000815180845261406981602086016020860161402d565b601f01601f19169290920160200192915050565b6020815260006140906020830184614051565b9392505050565b6000602082840312156140a957600080fd5b61409082613ff1565b8051825267ffffffffffffffff60208201511660208301526040810151613c08604084018280518252602090810151910152565b6080810161102082846140b2565b80356fffffffffffffffffffffffffffffffff81168114612ece57600080fd5b6000806040838503121561412757600080fd5b61413083613d28565b9150613fbe602084016140f4565b60006020828403121561415057600080fd5b61409082613d28565b6000806040838503121561416c57600080fd5b61417583613d28565b9150613fbe60208401613f69565b60008060008060a0858703121561419957600080fd5b6141a38686613def565b9350606085013567ffffffffffffffff8111156141bf57600080fd5b6141cb87828801613d3c565b90945092506141de905060808601613e07565b905092959194509250565b6000602082840312156141fb57600080fd5b61409082613e07565b600060a08284031215613e0157600080fd5b61422081846140b2565b60a0608082015268ffffffffffffffffff82511660a082015260006020830151604060c0840152610f4360e0840182614051565b60006020828403121561426657600080fd5b5035919050565b6000806040838503121561428057600080fd5b61401f83613e07565b60008083601f84011261429b57600080fd5b50813567ffffffffffffffff8111156142b357600080fd5b6020830191508360208260051b8501011115613d7e57600080fd5b600080602083850312156142e157600080fd5b823567ffffffffffffffff8111156142f857600080fd5b61430485828601614289565b90969095509350505050565b6000806000806060858703121561432657600080fd5b61432f85613d28565b935061433d60208601613ff1565b9250604085013567ffffffffffffffff81111561435957600080fd5b61436587828801613d3c565b95989497509550505050565b6000806000806060858703121561438757600080fd5b843567ffffffffffffffff81111561439e57600080fd5b6143aa87828801614289565b90955093506143bd905060208601613ff1565b91506141de60408601613ff1565b6000806000606084860312156143e057600080fd5b6143e984613d28565b92506143f7602085016140f4565b9150613f11604085016140f4565b6000806000838503608081121561441b57600080fd5b843567ffffffffffffffff81111561443257600080fd5b61443e87828801613f57565b9450506040601f198201121561445357600080fd5b50602084019150613f1160608501613e07565b60006060828403121561447857600080fd5b6140908383613def565b600181811c9082168061449657607f821691505b602082108103613e01577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082028115828204841417611020576110206144cf565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261458257614582614544565b500490565b67ffffffffffffffff8116811461208e57600080fd5b6000602082840312156145af57600080fd5b813561409081614587565b6000602082840312156145cc57600080fd5b61409082613f69565b6040516060810167ffffffffffffffff811182821017156145f8576145f8614515565b60405290565b6040805190810167ffffffffffffffff811182821017156145f8576145f8614515565b604051601f8201601f1916810167ffffffffffffffff8111828210171561464a5761464a614515565b604052919050565b600067ffffffffffffffff82111561466c5761466c614515565b50601f01601f191660200190565b600067ffffffffffffffff8084111561469557614695614515565b8360051b60206146a6818301614621565b8681529185019181810190368411156146be57600080fd5b865b84811015614784578035868111156146d85760008081fd5b880160603682900312156146ec5760008081fd5b6146f46145d5565b6146fd82613d28565b815261470a868301613ff1565b86820152604080830135898111156147225760008081fd5b929092019136601f8401126147375760008081fd5b823561474a61474582614652565b614621565b818152368983870101111561475f5760008081fd5b818986018a8301376000918101890191909152908201528452509183019183016146c0565b50979650505050505050565b600080858511156147a057600080fd5b838611156147ad57600080fd5b5050820193919092039150565b600084516147cc81846020890161402d565b8201838582376000930192835250909392505050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b60208152600061139f6020830184866147e2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec183360301811261488457600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126148c357600080fd5b83018035915067ffffffffffffffff8211156148de57600080fd5b602001915036819003821315613d7e57600080fd5b63ffffffff61490182613d28565b16825260208101356020830152604081013561491c81614587565b67ffffffffffffffff81166040840152505050565b61493b81896148f3565b86606082015260e06080820152600061495860e0830187896147e2565b6001600160a01b03861660a084015282810360c084015261497a8185876147e2565b9a9950505050505050505050565b60006020828403121561499a57600080fd5b815167ffffffffffffffff8111156149b157600080fd5b8201601f810184136149c257600080fd5b80516149d061474582614652565b8181528560208385010111156149e557600080fd5b610f4382602083016020860161402d565b68ffffffffffffffffff818116838216019080821115614a1857614a186144cf565b5092915050565b61ffff828116828216039080821115614a1857614a186144cf565b600061ffff808316818103614a5157614a516144cf565b6001019392505050565b600060408284031215614a6d57600080fd5b614a756145fe565b82358152602083013560208201528091505092915050565b68ffffffffffffffffff828116828216039080821115614a1857614a186144cf565b600068ffffffffffffffffff80841680614acb57614acb614544565b92169190910692915050565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a06080840152614b0d60e0840182614051565b905060608501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08483030160a0850152614b488282614051565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b600060408284031215614b8057600080fd5b614b886145fe565b9050815181526020820151602082015292915050565b600060408284031215614bb057600080fd5b6140908383614b6e565b600060808284031215614bcc57600080fd5b614bd46145d5565b825181526020830151614be681614587565b6020820152614bf88460408501614b6e565b60408201529392505050565b7fff000000000000000000000000000000000000000000000000000000000000008560f81b16815260007fffffffffffffffffffffffffffffffff00000000000000000000000000000000808660801b166001840152808560801b166011840152508251614c7981602185016020870161402d565b9190910160210195945050505050565b6fffffffffffffffffffffffffffffffff818116838216019080821115614a1857614a186144cf565b60008351614cc481846020880161402d565b835190830190614cd881836020880161402d565b01949350505050565b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b16815260008251614d1e81600285016020870161402d565b919091016002019392505050565b7fffff0000000000000000000000000000000000000000000000000000000000008135818116916002851015614d6c5780818660020360031b1b83161692505b505092915050565b8035602083101561102057600019602084900360031b1b1692915050565b7fffffffffffffffff0000000000000000000000000000000000000000000000008135818116916008851015614d6c5760089490940360031b84901b1690921692915050565b82815260008251614df081602085016020870161402d565b919091016020019392505050565b63ffffffff8516815268ffffffffffffffffff8416602082015269ffffffffffffffffffff831660408201526080606082015260006121726080830184614051565b601f821115613c08576000816000526020600020601f850160051c81016020861015614e695750805b601f850160051c820191505b81811015614e8857828155600101614e75565b505050505050565b815167ffffffffffffffff811115614eaa57614eaa614515565b614ebe81614eb88454614482565b84614e40565b602080601f831160018114614ef35760008415614edb5750858301515b600019600386901b1c1916600185901b178555614e88565b600085815260208120601f198616915b82811015614f2257888601518255948401946001909101908401614f03565b5085821015614f405787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b83811015614feb578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00185528151805163ffffffff1684528781015161ffff16888501528601516060878501819052614fd781860183614051565b968901969450505090860190600101614f79565b509098975050505050505050565b60008261500857615008614544565b500690565b80820180821115611020576110206144cf565b838152818360208301376000910160200190815292915050565b81810381811115611020576110206144cf565b600060ff821660ff8103615063576150636144cf565b60010192915050565b6fffffffffffffffffffffffffffffffff818116838216028082169190828114614d6c57614d6c6144cf565b60e081016150a682886148f3565b85606083015260ff851660808301526001600160a01b03841660a083015267ffffffffffffffff831660c08301529695505050505050565b6150e881876148f3565b8460608201526001600160a01b038416608082015267ffffffffffffffff831660a082015260e060c08201526000610c0d60e0830184614051565b7fff000000000000000000000000000000000000000000000000000000000000008660f81b1681527fffff0000000000000000000000000000000000000000000000000000000000008560f01b1660018201528360038201527fffffffffffffffff0000000000000000000000000000000000000000000000008360c01b166023820152600082516151bc81602b85016020870161402d565b91909101602b019695505050505050565b7fffffffffffffffffffffffffffffffff000000000000000000000000000000008135818116916010851015614d6c5760109490940360031b84901b1690921692915050565b7fff000000000000000000000000000000000000000000000000000000000000008135818116916001851015614d6c5760019490940360031b84901b169092169291505056fea26469706673582212204c1570096025a76a2e4ca153aea4e131278048f317a85384ee094b7ff1a7e86064736f6c63430008160033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001a44076050125825900e736c501f859c50fe728c0000000000000000000000004a79adc4539905376d339c69b6a7092d0598cc240000000000000000000000000000000000000000000000000000000000000200
-----Decoded View---------------
Arg [0] : _endpoint (address): 0x1a44076050125825900e736c501f859c50fE728c
Arg [1] : _owner (address): 0x4A79AdC4539905376D339C69b6a7092D0598cc24
Arg [2] : _queueCapacity (uint16): 512
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000001a44076050125825900e736c501f859c50fe728c
Arg [1] : 0000000000000000000000004a79adc4539905376d339c69b6a7092d0598cc24
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000200
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 29 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.