Funding Channel

Real-time funding payment notifications when funding settles on your positions.

Overview

Funding payments occur when you have an open position and a trade executes (either yours or someone else's that affects the funding rate). This channel provides instant notification of funding settlements, eliminating the need to poll the REST API.

Subscribe

{
  "method": "subscribe",
  "params": {
    "channel": "funding",
    "market_ids": [1, 2]
  }
}
ParameterTypeRequiredDescription
market_idsnumber[]NoFilter by market IDs. Empty = all markets
makersstring[]NoFilter by account addresses. Empty = authenticated account only

Message Format

Update

Sent when a funding payment is settled on your position.

{
  "channel": "funding",
  "type": "update",
  "market_id": "1",
  "data": {
    "account": "0x1234567890123456789012345678901234567890",
    "funding_payment": "-12340000000000000000",
    "position_size": "1500000000000000000",
    "last_checkpoint": "1230000000000000",
    "new_checkpoint": "1350000000000000"
  },
  "block_number": 33759944,
  "log_index": 42,
  "tx_hash": "0xabc123...",
  "block_timestamp": "1705317000000000000",
  "timestamp": "1705317000123456789"
}

Note: There is no snapshot for the funding channel. Funding payments are events, not state. Use the REST API to query historical funding payments.

Update Message Fields

FieldTypeDescription
channelstringAlways "funding"
typestringAlways "update"
market_idstringMarket ID
dataobjectFunding payment details
block_numbernumberBlockchain block number
log_indexnumberLog index within the block
tx_hashstringTransaction hash
block_timestampstringBlockchain timestamp (nanoseconds)
timestampstringServer timestamp (nanoseconds)

Funding Payment Data Fields

FieldTypeDescription
accountstringAccount address
funding_paymentstringFunding amount (wei, 18 decimals). See sign convention
position_sizestringPosition size at settlement (wei, 18 decimals)
last_checkpointstringPrevious accumulated funding checkpoint
new_checkpointstringNew accumulated funding checkpoint

Sign Convention

SignMeaning
positiveYou paid funding (deducted from balance)
negativeYou received funding (added to balance)

Example: Paying Funding

Long position when funding rate is positive (longs pay shorts):

{
  "funding_payment": "5000000000000000000",
  "position_size": "10000000000000000000"
}

This means: You paid 5 USDC in funding (5 * 10^18 wei).

Example: Receiving Funding

Short position when funding rate is positive (longs pay shorts):

{
  "funding_payment": "-5000000000000000000",
  "position_size": "-10000000000000000000"
}

This means: You received 5 USDC in funding (-5 * 10^18 wei).

Funding Calculation

Funding payment is calculated using the formula:

fundingPayment = (newCheckpoint - lastCheckpoint) * positionSize / 10^18

Where:

  • newCheckpoint is the accumulated funding rate at settlement
  • lastCheckpoint is your position's previous funding checkpoint
  • positionSize is your position size (positive for long, negative for short)

When Funding Settles

Funding payments are calculated and broadcast when:

  1. You execute a trade (open, close, or modify position)
  2. Someone else executes a trade in the same market

The funding is settled based on the time your position was held since the last checkpoint.

Examples

Subscribe to all funding payments

{
  "method": "subscribe",
  "params": {
    "channel": "funding"
  }
}

Subscribe to specific markets

{
  "method": "subscribe",
  "params": {
    "channel": "funding",
    "market_ids": [1, 2]
  }
}

Subscribe to specific accounts (internal only)

{
  "method": "subscribe",
  "params": {
    "channel": "funding",
    "makers": ["0x1234567890123456789012345678901234567890"]
  }
}

Unsubscribe

{
  "method": "unsubscribe",
  "params": {
    "channel": "funding"
  }
}

Authentication

The funding channel requires authentication. Unauthenticated clients cannot subscribe to this channel.

For authenticated users, if no makers filter is specified, the channel automatically filters to your own account's funding payments.

Related Channels

  • positions - Track your position changes
  • orders.events - Track order executions that may trigger funding