FeesLib

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "contracts/lib/FeesLib.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

/**
 * @title IERC20
 * @author MetaLend
 * @notice Minimal interface for ERC20 tokens to get decimals
 * @dev This interface is used to interact with ERC20 tokens to retrieve their decimal places
 */
interface IERC20 {
    function decimals() external view returns (uint8);
}

/**
 * @title FeesLib
 * @author MetaLend
 * @notice Library for managing fees
 * @dev This library provides extension helper functions for fee management
 */
library FeesLib {
    uint256 private constant _DENOMINATOR = 1000; // supports milli-tokens (0.001)

    /**
     * @notice Convert a fractional human-readable fee to raw token units
     * @param constantFee   The numerator for the fee (e.g. `1` if fee = 0.001 tokens with denominator = 1000)
     * @param token         The ERC20 token address
     * @return rawValue     The fee converted into token smallest units
     */
    function convertConstantFeeToRawValue(uint256 constantFee, address token) external view returns (uint256 rawValue) {
        uint8 decimals = IERC20(token).decimals();
        uint256 base = 10 ** decimals;

        // Scale fee proportionally to token decimals
        rawValue = (constantFee * base) / _DENOMINATOR;
    }
}
"
    }
  },
  "settings": {
    "metadata": {
      "bytecodeHash": "none",
      "useLiteralContent": true
    },
    "optimizer": {
      "enabled": true,
      "runs": 999999
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "paris"
  }
}}

Tags:
Factory|addr:0xdceac80c8429140450b45697aae1ccb8dc921ccb|verified:true|block:23520237|tx:0xc0e1fe4ec76cbdace30c5390fa814d29973f2bb159dba5d1f842826aee53af52|first_check:1759779162

Submitted on: 2025-10-06 21:32:44

Comments

Log in to comment.

No comments yet.