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


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;


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

uint256 public constant MAX_FEES_IN_BPS = 10000;


mapping(bytes32 => FeeInfo) private _feesInfo;



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


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


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


function calculateFeeAmount(uint256 tokensAmount_, uint256 feeInBps_)
    returns (uint256 feeAmount_);


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

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


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


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;





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)


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