PaymasterManagementFacet
Management facet for CMX paymaster diamond
Handles configuration, factory management, and administrative functions
Functions
onlyPaymasterManager
modifier onlyPaymasterManager();
onlyTreasuryManager
modifier onlyTreasuryManager();
onlyRateUpdater
modifier onlyRateUpdater();
depositCMX
Deposit CMX tokens to the paymaster for fee payments
function depositCMX(uint256 amount) external;
Parameters
amount
uint256
Amount of CMX tokens to deposit
withdrawCMX
Withdraw CMX tokens from the paymaster
function withdrawCMX(uint256 amount, address recipient) external onlyPaymasterManager;
Parameters
amount
uint256
Amount of CMX tokens to withdraw
recipient
address
Address to receive the tokens
getCMXBalance
Get CMX token balance of the paymaster
function getCMXBalance() external view returns (uint256 balance);
Returns
balance
uint256
Current CMX token balance
getUserCMXAllowance
Get user's CMX allowance for the paymaster
function getUserCMXAllowance(address user) external view returns (uint256 allowance);
Parameters
user
address
User address
Returns
allowance
uint256
Current CMX allowance
updateExchangeRate
Update CMX/ETH exchange rate
function updateExchangeRate(uint256 newRate) external onlyRateUpdater;
Parameters
newRate
uint256
New exchange rate (CMX tokens per 1 ETH, scaled by 1e18)
getExchangeRate
Get current CMX/ETH exchange rate
function getExchangeRate() external view returns (uint256 rate);
Returns
rate
uint256
Current exchange rate (CMX tokens per 1 ETH, scaled by 1e18)
calculateCMXAmount
Calculate CMX amount needed for a given ETH amount
function calculateCMXAmount(uint256 ethAmount) external view returns (uint256 cmxAmount);
Parameters
ethAmount
uint256
ETH amount in wei
Returns
cmxAmount
uint256
Required CMX amount
calculateETHEquivalent
Calculate ETH equivalent for a given CMX amount
function calculateETHEquivalent(uint256 cmxAmount) external view returns (uint256 ethAmount);
Parameters
cmxAmount
uint256
CMX amount
Returns
ethAmount
uint256
Equivalent ETH amount in wei
addSupportedFactory
Add a factory to the supported list
function addSupportedFactory(address factory, uint256 feeMultiplier) external onlyPaymasterManager;
Parameters
factory
address
Factory contract address
feeMultiplier
uint256
Fee multiplier for this factory (scaled by 1e18, 1e18 = 1x)
removeSupportedFactory
Remove a factory from the supported list
function removeSupportedFactory(address factory) external onlyPaymasterManager;
Parameters
factory
address
Factory contract address
updateFactoryFeeMultiplier
Update fee multiplier for a factory
function updateFactoryFeeMultiplier(address factory, uint256 feeMultiplier) external onlyPaymasterManager;
Parameters
factory
address
Factory contract address
feeMultiplier
uint256
New fee multiplier (scaled by 1e18)
isFactorySupported
Check if a factory is supported
function isFactorySupported(address factory) external view returns (bool supported);
Parameters
factory
address
Factory contract address
Returns
supported
bool
Whether the factory is supported
getFactoryFeeMultiplier
Get fee multiplier for a factory
function getFactoryFeeMultiplier(address factory) external view returns (uint256 multiplier);
Parameters
factory
address
Factory contract address
Returns
multiplier
uint256
Fee multiplier (scaled by 1e18)
getSupportedFactories
Get all supported factories
function getSupportedFactories() external view returns (address[] memory factories);
Returns
factories
address[]
Array of supported factory addresses
setProtocolTreasury
Set protocol treasury address
function setProtocolTreasury(address treasury) external onlyTreasuryManager;
Parameters
treasury
address
New treasury address
getProtocolTreasury
Get protocol treasury address
function getProtocolTreasury() external view returns (address treasury);
Returns
treasury
address
Current treasury address
transferFeesToTreasury
Transfer collected fees to protocol treasury
function transferFeesToTreasury(uint256 amount) external onlyTreasuryManager;
Parameters
amount
uint256
Amount of CMX tokens to transfer
getPaymasterStats
Get paymaster statistics
function getPaymasterStats()
external
view
returns (uint256 totalOperationsSponsored, uint256 totalCMXUsed, uint256 totalETHEquivalent);
Returns
totalOperationsSponsored
uint256
Total operations sponsored
totalCMXUsed
uint256
Total CMX tokens used for fees
totalETHEquivalent
uint256
Total ETH equivalent value
getUserStats
Get user-specific statistics
function getUserStats(address user)
external
view
returns (uint256 operationsSponsored, uint256 cmxUsed, uint256 ethEquivalent);
Parameters
user
address
User address
Returns
operationsSponsored
uint256
Operations sponsored for this user
cmxUsed
uint256
CMX tokens used by this user
ethEquivalent
uint256
ETH equivalent value for this user
addPaymasterManager
Add paymaster manager
function addPaymasterManager(address manager) external onlyPaymasterManager;
Parameters
manager
address
Address to add as manager
removePaymasterManager
Remove paymaster manager
function removePaymasterManager(address manager) external onlyPaymasterManager;
Parameters
manager
address
Address to remove as manager
addTreasuryManager
Add treasury manager
function addTreasuryManager(address manager) external onlyTreasuryManager;
Parameters
manager
address
Address to add as treasury manager
removeTreasuryManager
Remove treasury manager
function removeTreasuryManager(address manager) external onlyTreasuryManager;
Parameters
manager
address
Address to remove as treasury manager
addRateUpdater
Add rate updater
function addRateUpdater(address updater) external onlyPaymasterManager;
Parameters
updater
address
Address to add as rate updater
removeRateUpdater
Remove rate updater
function removeRateUpdater(address updater) external onlyPaymasterManager;
Parameters
updater
address
Address to remove as rate updater
updateMaxCMXPerOperation
Update maximum CMX per operation
function updateMaxCMXPerOperation(uint256 maxCMX) external onlyPaymasterManager;
Parameters
maxCMX
uint256
New maximum CMX per operation
updateMaxOperationsPerUser
Update maximum operations per user per day
function updateMaxOperationsPerUser(uint256 maxOps) external onlyPaymasterManager;
Parameters
maxOps
uint256
New maximum operations per user
updateTreasuryTransferThreshold
Update treasury transfer threshold
function updateTreasuryTransferThreshold(uint256 threshold) external onlyTreasuryManager;
Parameters
threshold
uint256
New threshold for auto-transfer to treasury
getConfiguration
Get current configuration
function getConfiguration()
external
view
returns (uint256 maxCMXPerOperation, uint256 maxOperationsPerUser, uint256 treasuryTransferThreshold);
Returns
maxCMXPerOperation
uint256
Maximum CMX per operation
maxOperationsPerUser
uint256
Maximum operations per user per day
treasuryTransferThreshold
uint256
Treasury transfer threshold
Last updated
Was this helpful?