Update healthcheck and display pnl on trades
This commit is contained in:
@@ -151,6 +151,9 @@ const HealthChecks: React.FC = () => {
|
||||
if (gmxData.data.responseTimeMs) {
|
||||
marketDetails['Response Time'] = `${gmxData.data.responseTimeMs}ms`;
|
||||
}
|
||||
if (gmxData.data.uiFeeFactor) {
|
||||
marketDetails['UI Fee Factor'] = gmxData.data.uiFeeFactor;
|
||||
}
|
||||
|
||||
// Add sample markets info (just count for details section)
|
||||
if (gmxData.data.sampleMarkets && Array.isArray(gmxData.data.sampleMarkets)) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {useState} from 'react'
|
||||
|
||||
const FeeCalculator: React.FC = () => {
|
||||
const [volumeUsd, setVolumeUsd] = useState<number>(1000000)
|
||||
const [uiFeePercent, setUiFeePercent] = useState<number>(0.002)
|
||||
const [rebatePercent, setRebatePercent] = useState<number>(10)
|
||||
const [volumeUsd, setVolumeUsd] = useState<number>(1400000)
|
||||
const [uiFeePercent, setUiFeePercent] = useState<number>(0.02)
|
||||
const [rebatePercent, setRebatePercent] = useState<number>(20)
|
||||
const [fundingFeeRate, setFundingFeeRate] = useState<number>(0.00371) // Based on example: ~0.065 USD for 1751 USD volume
|
||||
|
||||
// Based on the specific example: 10% rebate on $1751 = $0.0983
|
||||
// This means at 10% rebate, $1 of volume = $0.0000561393 rebated
|
||||
@@ -18,32 +19,39 @@ const FeeCalculator: React.FC = () => {
|
||||
// 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
|
||||
// Calculate funding fees based on the provided example (0.065 USD for 1751 USD)
|
||||
const dailyFundingFees = volumeUsd * (fundingFeeRate / 100)
|
||||
|
||||
// Total revenue is UI fees + rebates + funding fees
|
||||
const dailyTotalRevenue = dailyUiFees + dailyRebate + dailyFundingFees
|
||||
|
||||
return {
|
||||
daily: {
|
||||
volume: volumeUsd,
|
||||
uiFees: dailyUiFees,
|
||||
rebate: dailyRebate,
|
||||
fundingFees: dailyFundingFees,
|
||||
totalRevenue: dailyTotalRevenue
|
||||
},
|
||||
weekly: {
|
||||
volume: volumeUsd * 7,
|
||||
uiFees: dailyUiFees * 7,
|
||||
rebate: dailyRebate * 7,
|
||||
fundingFees: dailyFundingFees * 7,
|
||||
totalRevenue: dailyTotalRevenue * 7
|
||||
},
|
||||
monthly: {
|
||||
volume: volumeUsd * 30,
|
||||
uiFees: dailyUiFees * 30,
|
||||
rebate: dailyRebate * 30,
|
||||
fundingFees: dailyFundingFees * 30,
|
||||
totalRevenue: dailyTotalRevenue * 30
|
||||
},
|
||||
yearly: {
|
||||
volume: volumeUsd * 365,
|
||||
uiFees: dailyUiFees * 365,
|
||||
rebate: dailyRebate * 365,
|
||||
fundingFees: dailyFundingFees * 365,
|
||||
totalRevenue: dailyTotalRevenue * 365
|
||||
}
|
||||
}
|
||||
@@ -51,15 +59,16 @@ const FeeCalculator: React.FC = () => {
|
||||
|
||||
const fees = calculateFees()
|
||||
|
||||
// Test calculation: For $1751 with 10% rebate
|
||||
// Test calculations
|
||||
const testVolume = 1751
|
||||
const testRebate = testVolume * BASE_REBATE_PER_DOLLAR * (rebatePercent / 10)
|
||||
const testFundingFee = testVolume * (fundingFeeRate / 100)
|
||||
|
||||
return (
|
||||
<div className="container p-4">
|
||||
<h2 className="text-2xl font-bold mb-4">Platform Revenue Calculator</h2>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
||||
<div className="form-control">
|
||||
<label className="label">
|
||||
<span className="label-text">Daily Volume (USD)</span>
|
||||
@@ -98,6 +107,20 @@ const FeeCalculator: React.FC = () => {
|
||||
className="input input-bordered"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="form-control">
|
||||
<label className="label">
|
||||
<span className="label-text">Funding Fee Rate (%)</span>
|
||||
<span className="label-text-alt">Funding fees from agents</span>
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={fundingFeeRate}
|
||||
onChange={(e) => setFundingFeeRate(Number(e.target.value))}
|
||||
className="input input-bordered"
|
||||
step="0.0001"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-auto">
|
||||
@@ -108,6 +131,7 @@ const FeeCalculator: React.FC = () => {
|
||||
<th>Volume (USD)</th>
|
||||
<th>UI Fees (USD)</th>
|
||||
<th>Rebates (USD)</th>
|
||||
<th>Funding Fees (USD)</th>
|
||||
<th>Total Revenue (USD)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -117,6 +141,7 @@ const FeeCalculator: React.FC = () => {
|
||||
<td>${fees.daily.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}</td>
|
||||
<td>${fees.daily.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td>${fees.daily.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}</td>
|
||||
<td>${fees.daily.fundingFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td className="font-bold">${fees.daily.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -124,6 +149,7 @@ const FeeCalculator: React.FC = () => {
|
||||
<td>${fees.weekly.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}</td>
|
||||
<td>${fees.weekly.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td>${fees.weekly.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}</td>
|
||||
<td>${fees.weekly.fundingFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td className="font-bold">${fees.weekly.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -131,6 +157,7 @@ const FeeCalculator: React.FC = () => {
|
||||
<td>${fees.monthly.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}</td>
|
||||
<td>${fees.monthly.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td>${fees.monthly.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}</td>
|
||||
<td>${fees.monthly.fundingFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td className="font-bold">${fees.monthly.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -138,6 +165,7 @@ const FeeCalculator: React.FC = () => {
|
||||
<td>${fees.yearly.volume.toLocaleString(undefined, {maximumFractionDigits: 0})}</td>
|
||||
<td>${fees.yearly.uiFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td>${fees.yearly.rebate.toLocaleString(undefined, {minimumFractionDigits: 4, maximumFractionDigits: 4})}</td>
|
||||
<td>${fees.yearly.fundingFees.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td className="font-bold">${fees.yearly.totalRevenue.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -145,8 +173,12 @@ const FeeCalculator: React.FC = () => {
|
||||
</div>
|
||||
|
||||
<div className="alert alert-info mt-4">
|
||||
<div>
|
||||
<span className="font-semibold">Verification:</span> For a volume of $1751 with 10% rebate, the calculated rebate is ${testRebate.toFixed(4)} USD
|
||||
<div className="flex flex-col gap-1">
|
||||
<div>
|
||||
<span className="font-semibold">Verification:</span> For a volume of $1751:
|
||||
</div>
|
||||
<div className="pl-4">- With 10% rebate, the calculated rebate is ${testRebate.toFixed(4)} USD</div>
|
||||
<div className="pl-4">- The funding fee is ${testFundingFee.toFixed(2)} USD</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -155,7 +187,8 @@ const FeeCalculator: React.FC = () => {
|
||||
<ul className="list-disc pl-5 space-y-2">
|
||||
<li><strong>UI Fee:</strong> Charged on top of the base fee for transactions. For position operations, it's a percentage of the increase/decrease size.</li>
|
||||
<li><strong>Rebate:</strong> 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.</li>
|
||||
<li><strong>Total Revenue:</strong> The combined income from both UI fees and rebates.</li>
|
||||
<li><strong>Funding Fee:</strong> Fees generated by agents based on the trading volume. This is a percentage of the total volume.</li>
|
||||
<li><strong>Total Revenue:</strong> The combined income from UI fees, rebates, and funding fees.</li>
|
||||
</ul>
|
||||
|
||||
<h4 className="text-md font-semibold mt-4 mb-2">Fee Details</h4>
|
||||
@@ -164,7 +197,7 @@ const FeeCalculator: React.FC = () => {
|
||||
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%.
|
||||
</p>
|
||||
<p className="text-sm mt-2">
|
||||
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.
|
||||
Both UI fees, rebates, and funding fees contribute to the platform's revenue stream and can be used to cover on-chain transaction costs and other operational expenses.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user