Skip to content

Commit d61ff11

Browse files
authored
add OFT and xERC20 interface files for typechain generation (#938)
Signed-off-by: Ihor Farion <[email protected]>
1 parent 282a15a commit d61ff11

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
* @notice Interface for interfacing with Hyperlane's xERC20 messaging
6+
*/
7+
interface IHypXERC20Router {
8+
/**
9+
* @notice Retuns the underlying token available for bridging
10+
*/
11+
function wrappedToken() external view returns (address);
12+
13+
/**
14+
* @notice Returns the gas payment required to dispatch a message to the given domain's router.
15+
* @param _destinationDomain The domain of the router.
16+
* @return _gasPayment Payment computed by the registered InterchainGasPaymaster.
17+
*/
18+
function quoteGasPayment(uint32 _destinationDomain) external view returns (uint256);
19+
20+
/**
21+
* @notice Transfers `_amountOrId` token to `_recipient` on `_destination` domain.
22+
* @dev Delegates transfer logic to `_transferFromSender` implementation.
23+
* @dev Emits `SentTransferRemote` event on the origin chain.
24+
* @param _destination The identifier of the destination chain.
25+
* @param _recipient The address of the recipient on the destination chain.
26+
* @param _amountOrId The amount or identifier of tokens to be sent to the remote recipient.
27+
* @return messageId The identifier of the dispatched message.
28+
*/
29+
function transferRemote(
30+
uint32 _destination,
31+
bytes32 _recipient,
32+
uint256 _amountOrId
33+
) external payable returns (bytes32 messageId);
34+
}

contracts/interfaces/IOFT.sol

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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

Comments
 (0)