Fees
The Fees Module is a core component of the perpetual futures trading system. It calculates fees for opening and closing trades, manages fee tiers, implements a referral system, and distributes fees to various parties.
Key Concepts
Fee Structure
Base Fees: Every trade has base percentages for opening, closing, and conditional (trigger) orders.
Fee Multipliers: The base fees are adjusted by two multipliers:
Tier-based: High-volume traders earn points, which unlock a lower fee multiplier.
Referral: Referred traders receive a discount multiplier.
Effective Multiplier: The lowest of the applicable multipliers is used to calculate the final fee.
Liquidation Fees: These are a fixed percentage of the collateral and are not subject to the multipliers.
Trading Fee Schedule
Standard Trading Fees
Standard trading fees are calculated based on your total Position Size (Leverage × Collateral), not just your wallet balance.
Open Fee
0.10% (10 bps)
Charged on the total position size when you enter a trade.
Close Fee
0.10% (10 bps)
Charged on the total position size when you exit a trade.
Trigger Fee
0.01% (1 bp)
Charged only on automated orders (Limit, Stop Loss, Take Profit) to pay for the execution cost.
Fee Distribution
The Vault (LPs): Receives 25% of all Closing Fees to support platform stability and reward Liquidity Providers for their risk.
The Protocol (Gov): Receives the remaining 75% of Closing Fees and 100% of Open Fees. A portion of these fees is allocated to a pool for governance stakers.
Referrers: Earn a percentage of the fees generated by their referees from the governance staker portion.
Keepers (Bots): Receive 20% of the Trigger Fee for executing automated orders (Limit, Stop Loss, Take Profit); the remaining 80% goes to the Protocol.
Fee Lifecycle
1. Opening a Trade
When a user opens a trade, the system performs the following steps to calculate and process fees:
Determine Multiplier: It fetches the trader's fee tier and checks for a referral discount to find the effective fee multiplier.
Calculate Fees: The system calculates the adjusted open and trigger fees by applying the effective multiplier to the base fees.
Deduct and Distribute: The total fee is deducted from the trader's collateral and distributed. A portion goes to the trigger service provider (if applicable), a cut is allocated to the referrer, and the net amount is added to a pool for governance stakers.
2. Closing a Trade
When a user closes a trade, fees are handled differently depending on whether it's a normal closure or a liquidation.
Normal Closure: The system determines the effective multiplier, calculates adjusted close fees, and distributes them.
Liquidation: The fee is a fixed percentage of the trader's collateral, bypassing any fee tier or referral discounts. This fee is then split between the vault and governance stakers.
Liquidation Mechanics
Liquidation occurs when your collateral drops too low to support your position size. The protocol must force-close the trade to prevent bad debt.
Key Difference: Collateral vs. Position
Unlike standard trading fees (which are based on position size), Liquidation Fees are calculated based on your Remaining Collateral.
The Liquidation Penalty
If you are liquidated, the protocol seizes your remaining collateral. From this collateral, a 10% penalty is deducted and distributed as follows:
Closing Component (5% of Collateral):
Covers the cost of the vault closing the position.
Split: 20% goes to the Vault; 80% goes to the Protocol.
Trigger Component (5% of Collateral):
Rewards the entity that flagged and executed the liquidation.
Split: 20% goes to the Liquidator; 80% goes to the Protocol.
Priority of Payments (The "Waterfall")
If a user is liquidated and their collateral is nearly empty (insufficient to cover the full fees), the smart contract pays out in a specific priority order to protect the system:
First Priority → The Vault: The Vault gets its share first to ensure Liquidity Providers are protected.
Second Priority → The Liquidator: The bot gets its reward next.
Third Priority → The Protocol: The Government receives whatever is left.
Liquidation Example
You are liquidated while you have $100 of collateral remaining.
Total Penalty Calculation: $10.00 (10% of $100).
Distribution:
$1.00 goes to the Vault (20% of the Closing portion).
$1.00 goes to the Liquidator (20% of the Trigger portion).
$8.00 goes to the Protocol.
Outcome: The fees are paid, and the remaining collateral ($90) is seized by the protocol (added to government fees/insurance). Your collateral is zeroed.
Insufficient Collateral
If a trader's collateral is not sufficient to cover fees and losses, the fees are still accounted for in the internal ledgers (e.g., for governance and referrers) but are not physically transferred from the trader's collateral. The losses are absorbed by the Protocol Vault.
Last updated