Developer Docs
AppGitHub
  • Welcome!
  • Smart contracts
    • Core
      • Introduction
      • Deep Dive
      • Smart Contract Reference
        • PWN Hub
          • Tags
        • PWN Config
        • PWN Vault
        • Loan Types
          • Simple Loan
        • Proposals
          • Simple Loan Proposal
            • Simple Proposal
            • List Proposal
            • Elastic Proposal
            • Elastic Chainlink Proposal
            • Dutch Proposal
        • PWN Utilized Credit
        • PWN LOAN
        • PWN Revoked Nonce
        • Peripheral Contracts
          • Acceptor Controller
            • World ID
          • State Fingerprint Computer
            • UniV3
            • Chicken Bonds
          • Pool Adapter
            • Aave
            • Compound
            • ERC4626
        • Miscellaneous
          • PWN Fee Calculator
          • PWN Signature Checker
          • PWN Errors
          • PWN Periphery
          • Timelock
    • PWN DAO
      • Governance
        • Optimistic
        • Token
      • Tokens
        • PWN
        • stPWN
        • vePWN
          • Stake
          • Power
          • Metadata
      • Epoch Clock
      • Miscellaneous
        • Errors
        • EpochPowerLib
    • Tools
      • PWN Safe
        • Architecture
        • Security considerations
        • Smart Contract Reference
          • PWN Safe Factory
          • ATR Module
            • Tokenized Asset Manager
            • Recipient Permission Manager
          • Whitelist
          • ATR Guard
            • Operators context
      • Token Bundler
      • PWN Deployer
    • Libraries
      • MultiToken
    • Contract Addresses
  • More documentation
    • PWN Docs
    • FAQ
    • Audits
    • Using PWN without front-end
  • Deprecated
    • PWN Beta
      • Architecture
      • PWN
        • Off-chain signed offer
        • Offer types
      • PWN Vault
      • PWN LOAN
Powered by GitBook
On this page
  • 1. Summary
  • 2. Important links
  • 3. Contract details
Edit on GitHub
  1. Smart contracts
  2. Core
  3. Smart Contract Reference
  4. Miscellaneous

PWN Fee Calculator

PreviousMiscellaneousNextPWN Signature Checker

Last updated 9 months ago

1. Summary

PWNFeeCalculator.sol is a library that implements the calculateFeeAmount function to calculate the fee amount based on the protocol fee and the amount lent.

2. Important links

3. Contract details

  • PWNFeeCalculator.sol is written in Solidity version 0.8.16

calculateFeeAmount

Overview

Based on the protocol fee and the amount that is being lent, this function calculates and returns the fee and the amount lent with the fee deducted.

This function takes two arguments supplied by the caller:

  • uint16fee - Fee value in basis points. The value of 100 is a 1% fee.

  • uint256loanAmount - Amount of an asset used as a loan credit.

Implementation

function calculateFeeAmount(uint16 fee, uint256 loanAmount) internal pure returns (uint256 feeAmount, uint256 newLoanAmount) {
    if (fee == 0)
        return (0, loanAmount);

    feeAmount = Math.mulDiv(loanAmount, fee, 1e4);
    newLoanAmount = loanAmount - feeAmount;
}
pwn_contracts/PWNFeeCalculator.sol at master · PWNFinance/pwn_contractsGitHub
Logo