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;}