MureFee

Git Source

Inherits: OwnableUpgradeable, UUPSUpgradeable, FeeConfig

Author: Mure

Manages pool specific fee configuration and calculations. If specific config is not set for a pool; default fee config is applied. Fee configuration is stored in a mapping against an encoded key.

Upgradeable configuration contract governing Mure protocol fee settings

Implements Ownable for access control, UUPSUpgradeable for efficient upgrades, ERC165Upgradeable for interface support, and FeeConfig interface for compatibility checks.

State Variables

MureFeeStorageLocation

Struct hash for storage location keccak256(abi.encode(uint256(keccak256("mure.MureFee")) - 1)) & ~bytes32(uint256(0xff))

bytes32 private constant MureFeeStorageLocation = 0x5ce6e1025f6bcb2fbc14816760e865aaac081dc4c60162a5e592c26e03f6f100;

Functions

initialize

function initialize(address defaultFeeRecipient_, uint16 defaultFeePercentage_, address owner) external initializer;

setPoolFee

Sets fee configurations for a particular pool.

Requires the pool to exist. Can only be called by the contract owner.

function setPoolFee(address poolApp, string calldata poolName, uint16 feePercentage, address feeRecipient)
    external
    onlyOwner;

Parameters

NameTypeDescription
poolAppaddressaddress of the pool app
poolNamestringthe name of the pool
feePercentageuint16fee percentage in basis points
feeRecipientaddressaddress of the fee recipient

setDefaultFeeConfig

Sets the default fee configuration.

Can only be called by the contract owner.

function setDefaultFeeConfig(uint16 defaultFeePercentage_, address defaultFeeRecipient_) external onlyOwner;

Parameters

NameTypeDescription
defaultFeePercentage_uint16default fee percentage in basis points
defaultFeeRecipient_addressdefault address of the fee recipient

getPoolFee

Calculates the fee to be charged on amount.

function getPoolFee(address poolApp, string calldata poolName, uint256 amount)
    external
    view
    returns (uint256, address);

Parameters

NameTypeDescription
poolAppaddressaddress of the pool app
poolNamestringthe name of the pool
amountuint256

Returns

NameTypeDescription
<none>uint256fee amount and recipient
<none>address

poolFeePercentage

Retrieves the pool fee percentage.

function poolFeePercentage(address poolApp, string calldata poolName) public view returns (uint16 feePercentage);

Parameters

NameTypeDescription
poolAppaddressaddress of the pool app
poolNamestringthe name of the pool

Returns

NameTypeDescription
feePercentageuint16configured fee percentage

encodeHash

Calculates the encoded hash for pool config.

function encodeHash(address poolApp, string calldata poolName) public pure returns (bytes32);

Parameters

NameTypeDescription
poolAppaddressaddress of the pool app
poolNamestringthe name of the pool

Returns

NameTypeDescription
<none>bytes32encoded hash

supportsInterface

See IERC165-supportsInterface.

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool);

_calculateFee

Calculates the fee to be charged.

function _calculateFee(uint256 amount, uint256 feePercentage) private pure returns (uint256);

Parameters

NameTypeDescription
amountuint256total amount
feePercentageuint256fee percentage in basis points

_supportsPoolAppInterface

Checks if address supports the pool app interface.

function _supportsPoolAppInterface(address pool) private view returns (bool);

_getStorage

Retrieves the storage for the MureFee contract.

function _getStorage() private pure returns (MureFeeStorage storage $);

_authorizeUpgrade

required by the OZ UUPS module

function _authorizeUpgrade(address) internal override onlyOwner;

Events

FeeConfigSet

event FeeConfigSet(
    address indexed poolApp, string poolName, uint16 indexed feePercentage, address indexed feeRecipient
);

Structs

MureFeeStorage

struct MureFeeStorage {
    address defaultFeeRecipient;
    uint16 defaultFeePercentage;
    mapping(bytes32 => PoolFeeConfig) poolFee;
}