AbstractFeeModule

Git Source

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%)

uint256 public constant ZERO_FEES_IN_BPS = 0;

MAX_FEES_IN_BPS

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

uint256 public constant MAX_FEES_IN_BPS = 10000;

_feesInfo

mapping(bytes32 => FeeInfo) private _feesInfo;

Functions

getFeeInfo

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

getFeeInBps

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

getFeeRecipient

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

calculateFeeAmount

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.

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

_transferFees

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).

function _validateFeeInfo(FeeInfo memory feeInfo_) internal pure;

Parameters

NameTypeDescription

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)

Logo

Copyright © 2024 Frictionless Markets S.à.r.l