Funding is the primary mechanism to ensure that the last traded price perpetually anchors to the global spot price. It is similar to the interest cost of holding contracts in spot margin trading.
The funding fee is exchanged directly between buyers and sellers at the end of every funding interval. For example, 8-hour interval funding will occur at 16:00 UTC, 00:00 UTC, and 08:00 UTC.
When the funding rate is positive, long position holders pay the short position holders. Likewise, when the funding rate is negative, the short position holders pay the long position holders.
Traders will only pay or receive a funding fee if they hold a position at one of these times.
If traders close positions before funding, they will not pay or receive a funding fee.
Funding Fee calculation:
Funding Fee = Position Value x Funding Rate
Position Value = Quantity of Contract x Mark Price
Hence, upon execution, Trader A will pay a 48 USDT Taker's fee, and Trader B will pay an 8 USDT Maker’s fee.