From 741b2c3bb0132504e93b03c39f532f2556d9ed36 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Sat, 26 Apr 2025 04:10:21 +0700 Subject: [PATCH] add the file --- .../src/pages/toolsPage/feeCalculator.tsx | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 src/Managing.WebApp/src/pages/toolsPage/feeCalculator.tsx diff --git a/src/Managing.WebApp/src/pages/toolsPage/feeCalculator.tsx b/src/Managing.WebApp/src/pages/toolsPage/feeCalculator.tsx new file mode 100644 index 0000000..064c93c --- /dev/null +++ b/src/Managing.WebApp/src/pages/toolsPage/feeCalculator.tsx @@ -0,0 +1,174 @@ +import {useState} from 'react' + +const FeeCalculator: React.FC = () => { + const [volumeUsd, setVolumeUsd] = useState(1000000) + const [uiFeePercent, setUiFeePercent] = useState(0.002) + const [rebatePercent, setRebatePercent] = useState(10) + + // Based on the specific example: 10% rebate on $1751 = $0.0983 + // This means at 10% rebate, $1 of volume = $0.0000561393 rebated + // So the base rebate rate per $1 at 100% would be $0.000561393 + const BASE_REBATE_PER_DOLLAR = 0.0000561393 + + const calculateFees = () => { + // UI Fee is applied directly as a percentage of volume + const dailyUiFees = volumeUsd * (uiFeePercent / 100) + + // Calculate rebate based on the exact ratio provided + // For 10% rebate on $1751 resulting in $0.0983 rebate + const dailyRebate = volumeUsd * BASE_REBATE_PER_DOLLAR * (rebatePercent / 10) // Normalize to 10% base + + // Total revenue is UI fees plus rebates + const dailyTotalRevenue = dailyUiFees + dailyRebate + + return { + daily: { + volume: volumeUsd, + uiFees: dailyUiFees, + rebate: dailyRebate, + totalRevenue: dailyTotalRevenue + }, + weekly: { + volume: volumeUsd * 7, + uiFees: dailyUiFees * 7, + rebate: dailyRebate * 7, + totalRevenue: dailyTotalRevenue * 7 + }, + monthly: { + volume: volumeUsd * 30, + uiFees: dailyUiFees * 30, + rebate: dailyRebate * 30, + totalRevenue: dailyTotalRevenue * 30 + }, + yearly: { + volume: volumeUsd * 365, + uiFees: dailyUiFees * 365, + rebate: dailyRebate * 365, + totalRevenue: dailyTotalRevenue * 365 + } + } + } + + const fees = calculateFees() + + // Test calculation: For $1751 with 10% rebate + const testVolume = 1751 + const testRebate = testVolume * BASE_REBATE_PER_DOLLAR * (rebatePercent / 10) + + return ( +
+

Platform Revenue Calculator

+ +
+
+ + setVolumeUsd(Number(e.target.value))} + className="input input-bordered" + /> +
+ +
+ + setUiFeePercent(Number(e.target.value))} + className="input input-bordered" + step="0.001" + /> +
+ +
+ + setRebatePercent(Number(e.target.value))} + className="input input-bordered" + /> +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PeriodVolume (USD)UI Fees (USD)Rebates (USD)Total Revenue (USD)
Daily${fees.daily.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}${fees.daily.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}${fees.daily.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}${fees.daily.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
Weekly${fees.weekly.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}${fees.weekly.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}${fees.weekly.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}${fees.weekly.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
Monthly${fees.monthly.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}${fees.monthly.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}${fees.monthly.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}${fees.monthly.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
Yearly${fees.yearly.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}${fees.yearly.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}${fees.yearly.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}${fees.yearly.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}
+
+ +
+
+ Verification: For a volume of $1751 with 10% rebate, the calculated rebate is ${testRebate.toFixed(4)} USD +
+
+ +
+

How platform revenue is calculated

+
    +
  • UI Fee: Charged on top of the base fee for transactions. For position operations, it's a percentage of the increase/decrease size.
  • +
  • Rebate: Based on a ratio where $1 of volume with a 10% rebate generates $0.0000561393 of rebate. The actual rebate scales with both volume and rebate percentage.
  • +
  • Total Revenue: The combined income from both UI fees and rebates.
  • +
+ +

Fee Details

+

+ UI fees are charged on top of the base fee. The percentage amount is based on the amount configured for the uiFeeReceiver address. + The uiFeeFactor is a percentage value over 10^30. For example, if the uiFeeFactor is 2 * 10^25, the percentage charged would be 0.002%. +

+

+ Both UI fees and rebates contribute to the platform's revenue stream and can be used to cover on-chain transaction costs and other operational expenses. +

+
+
+ ) +} + +export default FeeCalculator