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.
Fee Distribution
Fees are distributed among four key parties:
Protocol Vault: Receives a portion of fees, primarily from closing trades, to support platform stability.
Governance Stakers: A portion of the fees is allocated to a pool for governance stakers.
Referrers: Referrers earn a percentage of the fees generated by their referees from the governance portion.
Trigger Service Providers: Off-chain services (keepers) that execute trigger orders receive a reward.
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.
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