Appearance
Solidity API
PropsFees
Implements fee management functionality for the Props system.
This contract manages fee structures for various operations in the Props system. It allows for setting, retrieving, and calculating fees based on different fee types and applications.
upsertFee
solidity
function upsertFee(string _feeType, uint256[] _feeAmounts, address[] _feeRecipients, enum PropsFeesStorage.FeeType _feeTypeEnum, enum PropsFeesStorage.FeeApplication _feeApplication, uint256 _tokenId) publicOnly accounts with FEE_MANAGER_ROLE can call this function.
Adds or updates a fee in the system.
Parameters
| Name | Type | Description |
|---|---|---|
| _feeType | string | The identifier for the fee type. |
| _feeAmounts | uint256[] | An array of fee amounts. |
| _feeRecipients | address[] | An array of addresses that will receive the fees. |
| _feeTypeEnum | enum PropsFeesStorage.FeeType | The type of fee (FLAT or PERCENTAGE). |
| _feeApplication | enum PropsFeesStorage.FeeApplication | How the fee is applied (PER_UNIT or PER_TRANSACTION). |
| _tokenId | uint256 | The ID of the token associated with this fee. |
getFee
solidity
function getFee(string _feeType) public view returns (uint256[] feeAmounts, address[] feeRecipients, enum PropsFeesStorage.FeeType feeType, enum PropsFeesStorage.FeeApplication feeApplication, uint256 tokenId)Returns default values if the fee doesn't exist.
Retrieves the details of a specific fee.
Parameters
| Name | Type | Description |
|---|---|---|
| _feeType | string | The identifier for the fee type. |
Return Values
| Name | Type | Description |
|---|---|---|
| feeAmounts | uint256[] | An array of fee amounts. |
| feeRecipients | address[] | An array of addresses that receive the fees. |
| feeType | enum PropsFeesStorage.FeeType | The type of fee (FLAT or PERCENTAGE). |
| feeApplication | enum PropsFeesStorage.FeeApplication | How the fee is applied (PER_UNIT or PER_TRANSACTION). |
| tokenId | uint256 | The ID of the token associated with this fee. |
getAllFees
solidity
function getAllFees() public view returns (string[] feeTypes, uint256[][] feeAmounts, address[][] feeRecipients, enum PropsFeesStorage.FeeType[] feeTypeEnums, enum PropsFeesStorage.FeeApplication[] feeApplications)This function may be gas-intensive for a large number of fees.
Retrieves all fees stored in the system.
Return Values
| Name | Type | Description |
|---|---|---|
| feeTypes | string[] | An array of fee type identifiers. |
| feeAmounts | uint256[][] | A 2D array of fee amounts for each fee type. |
| feeRecipients | address[][] | A 2D array of fee recipients for each fee type. |
| feeTypeEnums | enum PropsFeesStorage.FeeType[] | An array of fee types (FLAT or PERCENTAGE) for each fee. |
| feeApplications | enum PropsFeesStorage.FeeApplication[] | An array of fee applications (PER_UNIT or PER_TRANSACTION) for each fee. |
calculateFees
solidity
function calculateFees(string _feeType, uint256 _amount, uint256 _quantity) public view returns (uint256)For PERCENTAGE fees, the calculation assumes the percentage is in basis points (e.g., 100 = 1%).
Calculates the total fee for a given fee type, amount, and quantity.
Parameters
| Name | Type | Description |
|---|---|---|
| _feeType | string | The identifier for the fee type. |
| _amount | uint256 | The base amount to calculate the fee on. |
| _quantity | uint256 | The number of units (used for PER_UNIT fees). |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | The calculated total fee. |
removeFee
solidity
function removeFee(string _feeType) publicOnly accounts with FEE_MANAGER_ROLE can call this function.
Removes a fee from the system.
Parameters
| Name | Type | Description |
|---|---|---|
| _feeType | string | The identifier for the fee type to be removed. |
calculateTotalFees
solidity
function calculateTotalFees(string[] _prefixes, uint256 _tokenId, uint256 _quantity) public view returns (uint256 totalFee, address[] feeRecipients, uint256[] feeAmounts)This function calculates fees for all types: FLAT and PERCENTAGE.
Calculates the total fees for given fee prefixes, including all fee types.
Parameters
| Name | Type | Description |
|---|---|---|
| _prefixes | string[] | An array of fee prefixes to match against. |
| _tokenId | uint256 | The ID of the token associated with the fees. |
| _quantity | uint256 | The number of tokens or items. |
Return Values
| Name | Type | Description |
|---|---|---|
| totalFee | uint256 | The total calculated fee. |
| feeRecipients | address[] | An array of fee recipient addresses. |
| feeAmounts | uint256[] | An array of fee amounts corresponding to each recipient. |