@@ -18,6 +18,9 @@ interface IERC20Decimals {
18
18
contract OFTTransportAdapter {
19
19
using AddressToBytes32 for address ;
20
20
21
+ bytes public constant MSG_EMPTY_PARAM = new bytes (0 );
22
+ address public constant ZERO_ADDRESS = address (0 );
23
+
21
24
IERC20 public immutable usdt;
22
25
IOFT public immutable oftTransport;
23
26
@@ -49,8 +52,13 @@ contract OFTTransportAdapter {
49
52
return address (oftTransport) != address (0 ) && address (usdt) == _token;
50
53
}
51
54
55
+ /**
56
+ * @notice Transfers USDT from the current domain to the given address on the new domain.
57
+ * @dev This function will revert if the OFT bridge is disabled. I.e. if the zero address is passed to the constructor for the cctpTokenMessenger.
58
+ * @param _to Address to receive USDT on the new domain represented as bytes32.
59
+ * @param amount Amount of USDT to transfer.
60
+ */
52
61
function _transferUsdt (address _to , uint256 amount ) internal {
53
- // @dev: building `SendParam` struct
54
62
// receiver address converted to bytes32
55
63
bytes32 to = _to.toBytes32 ();
56
64
@@ -67,11 +75,19 @@ contract OFTTransportAdapter {
67
75
// bytes memory extraOptions = OptionsBuilder.newOptions(); // todo: this requires installing an extra lib `solidity-bytes-utils`
68
76
bytes memory extraOptions = new bytes (0 );
69
77
70
- // todo: can make these an immutable storage var, ZERO_BYTES? Idk
71
78
bytes memory composeMsg = new bytes (0 );
72
79
bytes memory oftCmd = new bytes (0 );
73
80
74
- SendParam memory sendParam = SendParam (dstEid, to, amountLD, minAmountLD, extraOptions, composeMsg, oftCmd);
81
+ // we don't use last 3 params to the `send()` call later, so we set them to zero bytes const, `MSG_EMPTY_PARAM`
82
+ SendParam memory sendParam = SendParam (
83
+ dstEid,
84
+ to,
85
+ amountLD,
86
+ minAmountLD,
87
+ MSG_EMPTY_PARAM,
88
+ MSG_EMPTY_PARAM,
89
+ MSG_EMPTY_PARAM
90
+ );
75
91
76
92
MessagingFee memory fee = oftTransport.quoteSend (sendParam, false );
77
93
@@ -80,7 +96,7 @@ contract OFTTransportAdapter {
80
96
(MessagingReceipt memory msgReceipt , OFTReceipt memory oftReceipt ) = oftTransport.send { value: fee.nativeFee }(
81
97
sendParam,
82
98
fee,
83
- address ( 0 )
99
+ ZERO_ADDRESS
84
100
);
85
101
86
102
// todo: possible further actions:
0 commit comments