FeeManager_v1.sol
FeeManager_v1
Inherits: ERC165Upgradeable, IFeeManager_v1, Ownable2StepUpgradeable
Author: Inverter Network
This contract manages the different fees possible on a protocol level. The different fees can be fetched publicly and be set by the owner of the contract.
Inherits from {ERC165Upgradeable} for interface detection, {Ownable2StepUpgradeable} for owner-based access control, and implements the {IFeeManager_v1} interface.
State Variables
BPS
Base Points used for percentage calculation. This value represents 100%.
uint public constant BPS = 10_000;
maxFee
The maximum fee percentage amount that can be set. Based on the BPS.
uint public maxFee;
defaultProtocolTreasury
The default protocol treasury address.
address internal defaultProtocolTreasury;
workflowTreasuries
The workflow treasury address. Orchestrator => treasury
mapping(address => address) internal workflowTreasuries;
defaultIssuanceFee
The default issuance fee percentage amount that apply unless workflow specific fees are set.
uint internal defaultIssuanceFee;
defaultCollateralFee
The default collateral fee percentage amount that apply unless workflow specific fees are set.
uint internal defaultCollateralFee;
workflowIssuanceFees
The workflow issuance fee. Orchestrator => hash(functionSelector + module address) => feeStruct.
mapping(address => mapping(bytes32 => Fee)) internal workflowIssuanceFees;
workflowCollateralFees
The workflow collateral fee. Orchestrator => hash(functionSelector + module address) => feeStruct.
mapping(address => mapping(bytes32 => Fee)) internal workflowCollateralFees;
__gap
Storage gap for future upgrades.
uint[50] private __gap;
Functions
supportsInterface
See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable)
returns (bool);
validAddress
Modifier to check if the given address is valid.
modifier validAddress(address adr);
validFee
Modifier to check if the given fee is valid.
modifier validFee(uint fee);
validMaxFee
Modifier to check if the given max fee is valid.
modifier validMaxFee(uint max);
constructor
constructor();
init
function init(
address owner,
address _defaultProtocolTreasury,
uint _defaultCollateralFee,
uint _defaultIssuanceFee
)
external
initializer
validAddress(owner)
validAddress(_defaultProtocolTreasury);
getDefaultProtocolTreasury
Returns the default treasury for all workflows.
function getDefaultProtocolTreasury() public view returns (address);
Returns
<none>
address
The address of the treasury.
getWorkflowTreasuries
Returns the treasury assigned to the given workflow.
function getWorkflowTreasuries(address workflow)
public
view
returns (address);
Parameters
workflow
address
The address of the workflow.
Returns
<none>
address
The address of the treasury.
getDefaultCollateralFee
Returns the default collateral fee for all workflows.
function getDefaultCollateralFee() external view returns (uint);
Returns
<none>
uint256
The collateral fee amount in relation to the BPS.
getDefaultIssuanceFee
Returns the default issuance fee for all workflows.
function getDefaultIssuanceFee() external view returns (uint);
Returns
<none>
uint256
The issuance fee amount in relation to the BPS.
getCollateralWorkflowFee
Returns the collateral fee for a specific workflow module function.
function getCollateralWorkflowFee(
address workflow,
address module,
bytes4 functionSelector
) public view returns (uint fee);
Parameters
workflow
address
The address of the workflow that contains the module function.
module
address
The address of the module that contains the function.
functionSelector
bytes4
The function selector of the target function.
Returns
fee
uint256
The collateral fee amount in relation to the BPS.
getIssuanceWorkflowFee
Returns the issuance fee for a specific workflow module function.
function getIssuanceWorkflowFee(
address workflow,
address module,
bytes4 functionSelector
) public view returns (uint fee);
Parameters
workflow
address
The address of the workflow that contains the module function.
module
address
The address of the module that contains the function.
functionSelector
bytes4
The function selector of the target function.
Returns
fee
uint256
The issuance fee amount in relation to the BPS.
getCollateralWorkflowFeeAndTreasury
Returns the collateral fee for a specific workflow module function and the according treasury address of the workflow.
function getCollateralWorkflowFeeAndTreasury(
address workflow,
address module,
bytes4 functionSelector
) external view returns (uint fee, address treasury);
Parameters
workflow
address
The address of the workflow that contains the module function.
module
address
The address of the module that contains the function.
functionSelector
bytes4
The function selector of the target function.
Returns
fee
uint256
The collateral fee amount in relation to the BPS.
treasury
address
The address of the treasury.
getIssuanceWorkflowFeeAndTreasury
Returns the issuance fee for a specific workflow module function and the according treasury address of the workflow.
function getIssuanceWorkflowFeeAndTreasury(
address workflow,
address module,
bytes4 functionSelector
) external view returns (uint fee, address treasury);
Parameters
workflow
address
The address of the workflow that contains the module function.
module
address
The address of the module that contains the function.
functionSelector
bytes4
The function selector of the target function.
Returns
fee
uint256
The issuance fee amount in relation to the BPS.
treasury
address
The address of the treasury.
setMaxFee
Sets the maximum fee percentage that can be assigned.
This function can only be called by the owner.
function setMaxFee(uint _maxFee) external onlyOwner validMaxFee(_maxFee);
Parameters
_maxFee
uint256
The max Fee in relation to the BPS.
setDefaultProtocolTreasury
Sets the default protocol treasury address.
This function can only be called by the owner.
function setDefaultProtocolTreasury(address _defaultProtocolTreasury)
external
onlyOwner
validAddress(_defaultProtocolTreasury);
Parameters
_defaultProtocolTreasury
address
The address of the default protocol treasury.
setWorkflowTreasury
Sets the protocol treasury address for a specific workflow.
This function can only be called by the owner.
function setWorkflowTreasury(address workflow, address treasury)
external
onlyOwner
validAddress(treasury);
Parameters
workflow
address
The address of the workflow.
treasury
address
The address of the protocol treasury for that specific workflow.
setDefaultCollateralFee
Sets the default collateral fee of the protocol.
This function can only be called by the owner.
function setDefaultCollateralFee(uint _defaultCollateralFee)
external
onlyOwner;
Parameters
_defaultCollateralFee
uint256
The default collateral fee of the protocol in relation to the BPS.
setDefaultIssuanceFee
Sets the default issuance fee of the protocol.
This function can only be called by the owner.
function setDefaultIssuanceFee(uint _defaultIssuanceFee) external onlyOwner;
Parameters
_defaultIssuanceFee
uint256
The default issuance fee of the protocol in relation to the BPS.
setCollateralWorkflowFee
Sets the collateral fee for a specific workflow module function.
This function can only be called by the owner.
function setCollateralWorkflowFee(
address workflow,
address module,
bytes4 functionSelector,
bool set,
uint fee
) external onlyOwner validFee(fee);
Parameters
workflow
address
The address of the workflow that contains the module function.
module
address
The address of the module that contains the function.
functionSelector
bytes4
The function selector of the target function.
set
bool
Boolean that determines if the fee is actually used or not.
fee
uint256
The collateral fee in relation to the BPS.
setIssuanceWorkflowFee
Sets the issuance fee for a specific workflow module function.
This function can only be called by the owner.
function setIssuanceWorkflowFee(
address workflow,
address module,
bytes4 functionSelector,
bool set,
uint fee
) external onlyOwner;
Parameters
workflow
address
The address of the workflow that contains the module function.
module
address
The address of the module that contains the function.
functionSelector
bytes4
The function selector of the target function.
set
bool
Boolean that determines if the fee is actually used or not.
fee
uint256
The issuance fee in relation to the BPS.
_getModuleFunctionHash
function _getModuleFunctionHash(address module, bytes4 functionSelector)
internal
pure
returns (bytes32);
_setDefaultProtocolTreasury
function _setDefaultProtocolTreasury(address _defaultProtocolTreasury)
internal
validAddress(_defaultProtocolTreasury);
_setWorkflowTreasury
function _setWorkflowTreasury(address workflow, address treasury)
internal
validAddress(treasury);
_setDefaultCollateralFee
function _setDefaultCollateralFee(uint _defaultCollateralFee)
internal
validFee(_defaultCollateralFee);
_setDefaultIssuanceFee
function _setDefaultIssuanceFee(uint _defaultIssuanceFee)
internal
validFee(_defaultIssuanceFee);
_setIssuanceWorkflowFee
function _setIssuanceWorkflowFee(
address workflow,
address module,
bytes4 functionSelector,
bool set,
uint fee
) internal validFee(fee);
_setMaxFee
function _setMaxFee(uint _maxFee) internal validMaxFee(_maxFee);
Last updated