ILayerZeroEndpoint.sol 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: BUSL-1.1
  2. pragma solidity >=0.5.0;
  3. import "./ILayerZeroUserApplicationConfig.sol";
  4. interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
  5. // @notice send a LayerZero message to the specified address at a LayerZero endpoint.
  6. // @param _dstChainId - the destination chain identifier
  7. // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
  8. // @param _payload - a custom bytes payload to send to the destination contract
  9. // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
  10. // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
  11. // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination
  12. function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;
  13. // @notice used by the messaging library to publish verified payload
  14. // @param _srcChainId - the source chain identifier
  15. // @param _srcAddress - the source contract (as bytes) at the source chain
  16. // @param _dstAddress - the address on destination chain
  17. // @param _nonce - the unbound message ordering nonce
  18. // @param _gasLimit - the gas limit for external contract execution
  19. // @param _payload - verified payload to send to the destination contract
  20. function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external;
  21. // @notice get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain
  22. // @param _srcChainId - the source chain identifier
  23. // @param _srcAddress - the source chain contract address
  24. function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
  25. // @notice get the outboundNonce from this source chain which, consequently, is always an EVM
  26. // @param _srcAddress - the source chain contract address
  27. function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
  28. // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
  29. // @param _dstChainId - the destination chain identifier
  30. // @param _userApplication - the user app address on this EVM chain
  31. // @param _payload - the custom message to send over LayerZero
  32. // @param _payInZRO - if false, user app pays the protocol fee in native token
  33. // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
  34. function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee);
  35. // @notice get this Endpoint's immutable source identifier
  36. function getChainId() external view returns (uint16);
  37. // @notice the interface to retry failed message on this Endpoint destination
  38. // @param _srcChainId - the source chain identifier
  39. // @param _srcAddress - the source chain contract address
  40. // @param _payload - the payload to be retried
  41. function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;
  42. // @notice query if any STORED payload (message blocking) at the endpoint.
  43. // @param _srcChainId - the source chain identifier
  44. // @param _srcAddress - the source chain contract address
  45. function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
  46. // @notice query if the _libraryAddress is valid for sending msgs.
  47. // @param _userApplication - the user app address on this EVM chain
  48. function getSendLibraryAddress(address _userApplication) external view returns (address);
  49. // @notice query if the _libraryAddress is valid for receiving msgs.
  50. // @param _userApplication - the user app address on this EVM chain
  51. function getReceiveLibraryAddress(address _userApplication) external view returns (address);
  52. // @notice query if the non-reentrancy guard for send() is on
  53. // @return true if the guard is on. false otherwise
  54. function isSendingPayload() external view returns (bool);
  55. // @notice query if the non-reentrancy guard for receive() is on
  56. // @return true if the guard is on. false otherwise
  57. function isReceivingPayload() external view returns (bool);
  58. // @notice get the configuration of the LayerZero messaging library of the specified version
  59. // @param _version - messaging library version
  60. // @param _chainId - the chainId for the pending config change
  61. // @param _userApplication - the contract address of the user application
  62. // @param _configType - type of configuration. every messaging library has its own convention.
  63. function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory);
  64. // @notice get the send() LayerZero messaging library version
  65. // @param _userApplication - the contract address of the user application
  66. function getSendVersion(address _userApplication) external view returns (uint16);
  67. // @notice get the lzReceive() LayerZero messaging library version
  68. // @param _userApplication - the contract address of the user application
  69. function getReceiveVersion(address _userApplication) external view returns (uint16);
  70. }