Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/PolynomialFeeCalculator.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "./interface/IFeeCalculator.sol";
contract PolynomialFeeCalculator is IFeeCalculator {
int256 public constant COEFFICIENT_SCALE = 1e18;
struct PolynomialCoefficients {
int256 a; // R⁴
int256 b; // R³
int256 c; // R²
int256 d; // R¹
}
PolynomialCoefficients public coefficients;
error InvalidRValue();
constructor() {
coefficients = PolynomialCoefficients({
a: -625 * COEFFICIENT_SCALE / 100, // -6.25
b: -1523 * COEFFICIENT_SCALE / 100, // -15.23
c: -242 * COEFFICIENT_SCALE / 100, // -2.42
d: -18 * COEFFICIENT_SCALE / 100 // -0.18
});
}
function calculateFee(int256 R) external view override returns (uint256 feeRateBps) {
if (R > 0) revert InvalidRValue();
// Price decline: Calculated using a polynomial curve
// F(R) = aR⁴ + bR³ + cR² + dR
int256 R2 = (R * R) / COEFFICIENT_SCALE;
int256 R3 = (R2 * R) / COEFFICIENT_SCALE;
int256 R4 = (R3 * R) / COEFFICIENT_SCALE;
int256 F_raw = 0;
F_raw += (coefficients.a * R4) / COEFFICIENT_SCALE;
F_raw += (coefficients.b * R3) / COEFFICIENT_SCALE;
F_raw += (coefficients.c * R2) / COEFFICIENT_SCALE;
F_raw += (coefficients.d * R) / COEFFICIENT_SCALE;
F_raw = (F_raw * 10000) / COEFFICIENT_SCALE;
if (F_raw < 0) F_raw = -F_raw;
feeRateBps = uint256(F_raw);
}
}
"
},
"src/interface/IFeeCalculator.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IFeeCalculator {
function calculateFee(int256 R) external view returns (uint256);
}
"
}
},
"settings": {
"remappings": [
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"permit2/=lib/v4-periphery/lib/permit2/",
"solmate/=lib/solmate/src/",
"v4-core/=lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}
}}
Submitted on: 2025-10-13 11:26:55
Comments
Log in to comment.
No comments yet.