IReactorFeeManager Interface
Overview
The IReactorFeeManager interface defines a set of functions to manage and retrieve fee-related configurations for Reactor messages. This includes managing payment tokens, setting per-caller and per-byte fees, and calculating total fees for a given message payload and destination.
Interface
interface IReactorFeeManager {
function actionFeeDiscounts(string calldata _action, address _paymentToken) external view returns (uint256);
function actionFees(string calldata _destinationName, string calldata _action, address _paymentToken) external view returns (uint256);
function callerFeeDiscounts(address _caller, address _paymentToken) external view returns (uint256);
function callerFees(string calldata _destinationName, address _caller, address _paymentToken) external view returns (uint256);
function destinationNameFeeDiscounts(string calldata _destinationName, address _paymentToken) external view returns (uint256);
function disablePaymentToken(address _paymentToken) external;
function enablePaymentToken(address _paymentToken) external;
function feeDiscounts(address _paymentToken) external view returns (uint256);
function feesPerByte(string calldata _destinationName, address _paymentToken) external view returns (uint256);
function getSendFee(string calldata _destinationName, string calldata _action, address _caller, address _paymentToken, uint256 _payloadSize) external view returns(uint256);
function maxPayloadSize() external view returns (uint256);
function paymentTokens(address _paymentToken) external view returns (bool);
function sendFees(string calldata _destinationName, address _paymentToken) external view returns (uint256);
function setActionFeeDiscounts(string[] calldata _actions, address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setActionFees(string[] calldata _destinationNames, string[] calldata _actions, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
function setCallerFeeDiscounts(address[] calldata _callers, address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setCallerFees(string[] calldata _destinationNames, address[] calldata _callers, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
function setDestinationNameFeeDiscounts(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setFeeDiscounts(address[] calldata _paymentTokens, uint256[] calldata _discounts) external;
function setFeesPerByte(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
function setMaxPayloadSize(uint256 _maxPayloadSize) external;
function setSendFees(string[] calldata _destinationNames, address[] calldata _paymentTokens, uint256[] calldata _fees) external;
}Function Details
callerFees
function callerFees(
string calldata _destinationName,
address _caller,
address _paymentToken
) external view returns (uint256);Retrieves the fixed fee set for a specific caller for a given payment token and destination.
_destinationName: Name of the target chain._caller: Address of the caller._paymentToken: Address of the payment token.
disablePaymentToken
function disablePaymentToken(address _paymentToken) external;Disables a specific payment token, making it invalid for fee payment.
_paymentToken: Address of the token to disable.
enablePaymentToken
function enablePaymentToken(address _paymentToken) external;Enables a specific token for use in fee payments.
_paymentToken: Address of the token to enable.
feesPerByte
function feesPerByte(
string calldata _destinationName,
address _paymentToken
) external view returns (uint256);
Gets the fee per byte of payload data for a specific token and destination.
_destinationName: Target chain’s name._paymentToken: Address of the token used for payment.
getSendFee
function getSendFee(
string calldata _destinationName,
address _caller,
address _paymentToken,
uint256 _payloadSize
) external view returns (uint256);Calculates the total fee to send a message based on the caller, payment token, destination, and payload size.
_destinationName: Target chain._caller: Sender’s address._paymentToken: Token used for payment._payloadSize: Size of the payload in bytes.
paymentTokens
function paymentTokens(address _paymentToken) external view returns (bool);Checks whether a token is currently enabled for payments.
_paymentToken: Address of the token.
sendFees
function sendFees(
string calldata _destinationName,
address _paymentToken
) external view returns (uint256);Returns the base fee for sending messages to a specific destination using a given token.
_destinationName: Name of the destination._paymentToken: Token used for the fee.
setCallerFees
function setCallerFees(
string calldata _destinationName,
address _caller,
address[] calldata _paymentTokens,
uint256[] calldata _fees
) external;Sets a fixed fee for a specific caller, token, and destination.
_destinationName: Chain to which the fees applies._caller: Address for which the fee is configured._paymentTokens: List of token addresses._fees: List of fee values to assign.
setFeesPerByte
function setFeesPerByte(
string calldata _destinationName,
address[] calldata _paymentTokens,
uint256[] calldata _fees
) external;Configures the per-byte fee for sending payloads to a specific chain with a given token.
_destinationName: Chain to which the fees applies._paymentTokens: List of token addresses._feePerBytes: List of fee per byte values to assign.
setSendFees
function setSendFees(
string calldata _destinationName,
address[] calldata _paymentTokens,
uint256[] calldata _fees
) external;Sets the base send fee for a specific token and destination.
_destinationName: Chain to which the fees applies._paymentTokens: List of token addresses._fees: List of fee values to assign.
Usage Notes
- This interface is typically implemented by a contract that manages the fee logic for a cross-chain messaging system.
- Functions like
set*are likely to be restricted to only authorized administrators. - Always validate that the
paymentTokenis enabled before proceeding with fee-related calculations. - When setting fees, make sure the number of token addresses equal the number of fees and that the position of the token/fee pair are the same (i.e. the fee in the first position of
_feesis the fee for the token in the first position of_paymentTokens).