šŸ’°
Sudo Gitbook
  • šŸ‘‹Welcome to Sudo
  • Overview
    • šŸ’”What is Sudo
    • ✨Sudo Features
  • Trade on Sudo
    • šŸ’ŽStart trading
      • Supported Assets
      • Fees
      • Market Hours
    • šŸ“šEducational Resources
      • What Are Perpetual Futures?
      • Using Leverage Wisely
      • Risk Management Fundamentals
      • What is Sharpe Ratio
      • Real Trading Scenarios
      • Avoiding Rookie Mistakes
  • Liquidity Providers
    • šŸ’°How to provide liquidity
    • šŸ›°ļøSLP
    • šŸ¦SLP Staking
  • S Rewards
    • S Card
      • Getting S Card
      • S Points
      • Using Your S Card
  • Sudo API
    • Sudo API Reference
      • Trader Data
      • Market Info
  • Sudo SDK
    • Introduction to Sudo SDK
    • Core Concepts
    • Installation and Setup
    • Quick Start
    • šŸ“šv0.0.6
      • API Reference
        • SudoAPI
          • Open Position
          • Decrease Position
          • Pledge In Position
          • Redeem From Position
          • Cancel Order
          • getPositionCapInfoList
          • getPositionInfoList
          • getPositionConfig
        • OracleAPI
          • subOraclePrices
      • Changelog
    • Best Practices
    • Troubleshooting
  • Feature Details
    • Algorithm Balanced Funding Rate (ABFR)
    • Risk control
    • FAQ
    • Roadmap
    • On-chain program
Powered by GitBook
On this page
  1. Feature Details

Algorithm Balanced Funding Rate (ABFR)

PreviousTroubleshootingNextRisk control

Last updated 9 months ago

The fundamental principle underlying ABFR is to safeguard the interests of SLP holders by dynamically adapting the funding rate according to the specific direction of a trading pair. When traders exhibit net profitability in a given trading pair, fees are gathered from them and provided as support to LPs. When traders face an overall loss, fees are acquired from LPs and allocated to traders. This mechanism guarantees that the combined unrealized and realized PNL of each trading pair tends to balance out to approximately zero over the long run. In this way, LPs wouldn't experience excessive returns but rather would generate income from fees (transaction fee + borrowing interest). The subsequent steps outline the overall process for calculating these dynamic funding fees.

Calculate the total profit and loss of LP at time t on the the trading pair

sign={1shortāˆ’1longĪ”t=openAmounttƗpricetāˆ’openSizetpnlt=realizedPnl+fundingFee+signĆ—Ī”t\begin{aligned}sign&=\begin{cases}1&short\\-1&long\end{cases}\\\Delta_t&=openAmount_t \times price_t - openSize_t\\pnl_t&=realizedPnl+fundingFee+sign\times\Delta_t\end{aligned}signĪ”t​pnlt​​={1āˆ’1​shortlong​=openAmountt​×pricetā€‹āˆ’openSizet​=realizedPnl+fundingFee+signĆ—Ī”t​​

  • Realized PNL signifies the actual profit and loss experienced by LPs due to changes in traders' positions, excluding the influence of fees.

  • FundingFee embodies the cumulative funding fees that have been gathered or distributed.

When PNL_t < 0:

ABFRt=min{K1Ɨlog∣PNLt∣,Rx}ABFR_t=\begin{aligned}min\left\{K_1\times log\left|PNL_t\right|,R_x\right\}\end{aligned}ABFRt​=min{K1​×log∣PNLtā€‹āˆ£,Rx​}​

When PNL_t > 0:

ABFRt=āˆ’min{K2Ɨlog∣PNLt∣,Ry}ABFR_t=\begin{aligned}-min\left\{K_2\times log\left|PNL_t\right|,R_y\right\}\end{aligned}ABFRt​=āˆ’min{K2​×log∣PNLtā€‹āˆ£,Ry​}​

K1, K2 are constant coefficients

  • The reason for using the logarithm of pnl is to make ABFR change significantly when pnl is small and change slowly when pnl is large

  • ABFR has upper and lower bounds, with corresponding upper and lower rate limits Rx, Ry when pnl < 0 and pnl > 0, respectively

If a trader opens a position at time t1 and closes it at time t2, with a position size of size, the funding fee to be paid/received by the trader is

fundingFee=sizeĆ—āˆ«t1t2ABFRtĀ dtfundingFee=size\times\int_{t_1}^{t_2}ABFR_t\ dtfundingFee=sizeĆ—āˆ«t1​t2​​ABFRt​ dt

When the fee is positive, trader pays the funding fee to the LP

When the fee is negative, LP pays the funding fee to the trader