|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +/** |
| 5 | + * @notice This file contains minimal copies of relevant structs / interfaces for OFT bridging. Source code link: |
| 6 | + * https://github.com/LayerZero-Labs/LayerZero-v2/blob/9a4049ae3a374e1c0ef01ac9fb53dd83f4257a68/packages/layerzero-v2/evm/oapp/contracts/oft/interfaces/IOFT.sol |
| 7 | + * It's also published as a part of an npm package: @layerzerolabs/oft-evm. The published code is incompatible with |
| 8 | + * our compiler version requirements, so we copy it here instead |
| 9 | + */ |
| 10 | + |
| 11 | +struct MessagingReceipt { |
| 12 | + bytes32 guid; |
| 13 | + uint64 nonce; |
| 14 | + MessagingFee fee; |
| 15 | +} |
| 16 | + |
| 17 | +struct MessagingFee { |
| 18 | + uint256 nativeFee; |
| 19 | + uint256 lzTokenFee; |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * @dev Struct representing token parameters for the OFT send() operation. |
| 24 | + */ |
| 25 | +struct SendParam { |
| 26 | + uint32 dstEid; // Destination endpoint ID. |
| 27 | + bytes32 to; // Recipient address. |
| 28 | + uint256 amountLD; // Amount to send in local decimals. |
| 29 | + uint256 minAmountLD; // Minimum amount to send in local decimals. |
| 30 | + bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message. |
| 31 | + bytes composeMsg; // The composed message for the send() operation. |
| 32 | + bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations. |
| 33 | +} |
| 34 | + |
| 35 | +/** |
| 36 | + * @dev Struct representing OFT receipt information. |
| 37 | + */ |
| 38 | +struct OFTReceipt { |
| 39 | + uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals. |
| 40 | + // @dev In non-default implementations, the amountReceivedLD COULD differ from this value. |
| 41 | + uint256 amountReceivedLD; // Amount of tokens to be received on the remote side. |
| 42 | +} |
| 43 | + |
| 44 | +/** |
| 45 | + * @title IOFT |
| 46 | + * @dev Interface for the OftChain (OFT) token. |
| 47 | + * @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well. |
| 48 | + * @dev This specific interface ID is '0x02e49c2c'. |
| 49 | + */ |
| 50 | +interface IOFT { |
| 51 | + /** |
| 52 | + * @notice Retrieves the address of the token associated with the OFT. |
| 53 | + * @return token The address of the ERC20 token implementation. |
| 54 | + */ |
| 55 | + function token() external view returns (address); |
| 56 | + |
| 57 | + /** |
| 58 | + * @notice Provides a quote for the send() operation. |
| 59 | + * @param _sendParam The parameters for the send() operation. |
| 60 | + * @param _payInLzToken Flag indicating whether the caller is paying in the LZ token. |
| 61 | + * @return fee The calculated LayerZero messaging fee from the send() operation. |
| 62 | + * |
| 63 | + * @dev MessagingFee: LayerZero msg fee |
| 64 | + * - nativeFee: The native fee. |
| 65 | + * - lzTokenFee: The lzToken fee. |
| 66 | + */ |
| 67 | + function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory); |
| 68 | + |
| 69 | + /** |
| 70 | + * @notice Executes the send() operation. |
| 71 | + * @param _sendParam The parameters for the send operation. |
| 72 | + * @param _fee The fee information supplied by the caller. |
| 73 | + * - nativeFee: The native fee. |
| 74 | + * - lzTokenFee: The lzToken fee. |
| 75 | + * @param _refundAddress The address to receive any excess funds from fees etc. on the src. |
| 76 | + * @return receipt The LayerZero messaging receipt from the send() operation. |
| 77 | + * @return oftReceipt The OFT receipt information. |
| 78 | + * |
| 79 | + * @dev MessagingReceipt: LayerZero msg receipt |
| 80 | + * - guid: The unique identifier for the sent message. |
| 81 | + * - nonce: The nonce of the sent message. |
| 82 | + * - fee: The LayerZero fee incurred for the message. |
| 83 | + */ |
| 84 | + function send( |
| 85 | + SendParam calldata _sendParam, |
| 86 | + MessagingFee calldata _fee, |
| 87 | + address _refundAddress |
| 88 | + ) external payable returns (MessagingReceipt memory, OFTReceipt memory); |
| 89 | +} |
0 commit comments