# AbstractFeeModule

[Git Source](https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/blob/85f6dfa54ce0787eb1b1345bd6726f84fe766c54/contracts/abstract/AbstractFeeModule.sol)

**Inherits:** IAbstractFeeModule

Copyright © 2023 DEFYCA Labs S.à.r.l Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DEFYCA LABS S.à.r.l BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## State Variables

### ZERO\_FEES\_IN\_BPS

*Use `SafeERC20` for any ERC20 token in the conversion*

*represents 0 bps in fees (the minima of fees or 0%)*

```solidity
uint256 public constant ZERO_FEES_IN_BPS = 0;
```

### MAX\_FEES\_IN\_BPS

*represents 10000 bps in fees (the maxima of fees or 100%)*

```solidity
uint256 public constant MAX_FEES_IN_BPS = 10000;
```

### \_feesInfo

```solidity
mapping(bytes32 => FeeInfo) private _feesInfo;
```

## Functions

### getFeeInfo

```solidity
function getFeeInfo(bytes32 tokenFeeKey_) public view override returns (FeeInfo memory);
```

### getFeeInBps

```solidity
function getFeeInBps(bytes32 tokenFeeKey_) public view override returns (uint256);
```

### getFeeRecipient

```solidity
function getFeeRecipient(bytes32 tokenFeeKey_) public view override returns (address);
```

### calculateFeeAmount

```solidity
function calculateFeeAmount(uint256 tokensAmount_, uint256 feeInBps_)
    public
    pure
    override
    returns (uint256 feeAmount_);
```

### \_setTokenFee

*Shouldnt arrise due to validation, but being doubly sure, we can't compute incorrect fees.*

```solidity
function _setTokenFee(bytes32 feeKey_, FeeInfo memory feeInfo_) internal;
```

### \_transferFees

```solidity
function _transferFees(bytes32 feeKey_, IERC20 token_, address tokenSender_, uint256 tokensAmount_)
    internal
    returns (uint256);
```

### \_validateFeeInfo

*Validates the FeeInfo, specifically validates the non zero address of the feeRecipientAddr and the range for the feeInBps (0 to MAX\_FEES\_IN\_BPS).*

```solidity
function _validateFeeInfo(FeeInfo memory feeInfo_) internal pure;
```

**Parameters**

| Name       | Type      | Description                                                                                                                                                                                                                                 |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `feeInfo_` | `FeeInfo` | the FeeInfo to validate. throws `AbstractFeeModuleInvalidFeeRecipient` if the feeRecipientAddr is a zero address throws `AbstractFeeModuleInvalidFee` if the feeInBps is not in the valid range (ZERO\_FEES\_IN\_BPS to MAX\_FEES\_IN\_BPS) |
