Fees API

Query fee data including transaction-level fees, daily statistics, and protocol/trader summaries.

Table of Contents

Queries

feeTransaction

Get a specific fee transaction by ID.

Signature:

feeTransaction(id: ID!): FeeTransaction

Parameters:

  • id: Transaction ID (string)

Returns: FeeTransaction object or null

Example:


feeTransactions

List fee transactions with filtering and pagination.

Signature:

Parameters:

  • filter: Filter object (optional)

    • traderAddress: Filter by trader

    • collateralDenom: Filter by collateral token

    • feeType: Filter by OPENING or CLOSING

    • fromDate: Start date (RFC3339)

    • toDate: End date (RFC3339)

    • minAmount: Minimum fee amount

    • maxAmount: Maximum fee amount

  • limit: Max results (default: 100)

  • offset: Skip results (default: 0)

Returns: Array of FeeTransaction objects

Example - Get User Fees:

Example - Filter by Date Range:

Example - Large Fees Only:

Use Cases:

  • User fee history

  • Protocol fee monitoring

  • Large transaction tracking

  • Fee analysis by period


feeDailyStats

Get aggregated daily fee statistics.

Signature:

Parameters:

  • filter: Filter object (optional)

    • traderAddress: Filter by specific trader

    • collateralDenom: Filter by collateral token

    • fromDate: Start date

    • toDate: End date

    • protocolWide: If true, get protocol-wide stats

  • limit: Max results (default: 30)

  • offset: Skip results (default: 0)

Returns: Array of FeeDailyStats objects

Example - Protocol Daily Stats:

Example - Trader Daily Stats:

Use Cases:

  • Daily fee charts

  • Historical fee analysis

  • Revenue tracking

  • Trader fee breakdown


feeAnalytics

Get enhanced fee analytics with additional metrics.

Signature:

Parameters: Same as feeDailyStats

Returns: Array of FeeAnalytics objects

Example:

Key Differences from feeDailyStats:

  • Includes avgFeeMultiplier

  • Includes totalFeesAll (sum of opening + closing)

  • More granular trigger fee breakdown

Use Cases:

  • Advanced analytics dashboards

  • Fee multiplier tracking

  • Comprehensive fee reports


protocolFeeSummary

Get protocol-wide fee summary for a time period.

Signature:

Parameters:

  • collateralDenom: Optional collateral filter

  • fromDate: Start date (optional)

  • toDate: End date (optional)

Returns: ProtocolFeeSummary object

Example - All-Time Protocol Summary:

Example - Monthly Summary:

Example - Per-Collateral Summary:

Use Cases:

  • Protocol revenue reports

  • KPI tracking

  • Performance metrics

  • Time-period comparisons


traderFeeSummary

Get fee summary for a specific trader.

Signature:

Parameters:

  • traderAddress: Trader's address (required)

  • collateralDenom: Optional collateral filter

  • fromDate: Start date (optional)

  • toDate: End date (optional)

Returns: TraderFeeSummary object

Example - All-Time Trader Summary:

Example - Monthly Trader Summary:

Use Cases:

  • User dashboards

  • Trading cost analysis

  • Fee optimization insights

  • Referral tracking


Types Reference

FeeTransaction

Complete fee transaction details.

Key Fields:

  • totalFeeCharged: Total fee paid by trader

  • govFee: Fee to protocol governance

  • vaultFee: Fee to LP vault

  • referrerAllocation: Fee to referrer (if any)

  • triggerFee: Fee paid to order trigger executor

  • badDebt: Bad debt if position liquidated with insufficient collateral

  • feeMultiplier: Dynamic fee multiplier applied


FeeDailyStats

Daily aggregated fee statistics.


FeeAnalytics

Enhanced analytics with additional metrics.


ProtocolFeeSummary

Protocol-wide fee summary.


TraderFeeSummary

Per-trader fee summary.


Enums

FeeType:

  • OPENING: Fees charged when opening positions

  • CLOSING: Fees charged when closing positions


Fee Calculations

Total Protocol Revenue

Average Fee Per Trade

Fee Breakdown Percentages

Convert Fee Amounts


Best Practices

Date Range Queries

Pagination for Large Datasets

Caching Daily Stats

Last updated