Skip to content

Instantly share code, notes, and snippets.

@jac18281828
Created June 18, 2024 19:35
Show Gist options
  • Save jac18281828/a7c2926a6ebca60a2ecd4c7f0d727336 to your computer and use it in GitHub Desktop.
Save jac18281828/a7c2926a6ebca60a2ecd4c7f0d727336 to your computer and use it in GitHub Desktop.
Remix Quote Send for OFT
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;
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.
}
struct MessagingFee {
uint256 nativeFee;
uint256 lzTokenFee;
}
interface ETHx_OFTAdapter {
function quoteSend(
SendParam calldata _sendParam,
bool _payInLzToken
) external view returns (MessagingFee memory msgFee);
}
/**
* @custom:dev-run-script .
*/
contract QuoteSend {
event MessageFeePublished(uint256 nativeFee);
address public constant OFT_ADAPTER = address(0x39d0ce7d1509a4f22619D0f666978FBe820665E9);
function quoteFee() public {
// arbitrum 30110
// optimism 30111
uint32 destEid = 30110;
address destAccount = msg.sender;
uint256 tokensToSend = 10000000000000000;
ETHx_OFTAdapter adapter = ETHx_OFTAdapter(OFT_ADAPTER);
bytes memory options = hex"00030100110100000000000000000000000000030d40";
SendParam memory sendParam =
SendParam(destEid, addressToBytes32(destAccount), tokensToSend, tokensToSend, options, "", "");
MessagingFee memory fee = adapter.quoteSend(sendParam, false);
emit MessageFeePublished(fee.nativeFee);
}
function addressToBytes32(address addr) internal pure returns (bytes32) {
return bytes32(uint256(uint160(addr)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment